Re: [hlcoders] bf_write and unsigned characters

2006-06-04 Thread James
--
[ Picked text/plain from multipart/alternative ]
I've found my problem: It seems I need to make the messages I send UTF-8
encoded where as I was just sending my messages before in plain ANSI. The
characters 128 must have been recognized as part of the UTF-8 encoding and
thus were incomplete since the following characters were normal characters;
so I presume the offending 128 characters were simply ignored.

On 6/3/06, John Sheu [EMAIL PROTECTED] wrote:

  However, when I attempt to write out a message that contains characters
 that
  are greater than 128 (unsigned) in byte size, they get stripped. I've
 also
  tried replacing the WriteChar() in the WriteString() function with
  WriteByte() but I still get the same result. Is there any way to write
 these
  kind of characters into a bf_write? Or is this problem occurring
 somewhere
  else downstream where these characters may be getting stripped?

 What's stripped?  Are they being clamped to 128?  Or is it possible
 that it's being wrapped around to -127?

 I've had issues before with bf_read/bf_write and casting signed/unsigned
 chars.  It usually comes down to making sure that you aren't making any
 unneccessary casts.

 -John Sheu

 ___
 To unsubscribe, edit your list preferences, or view the list archives,
 please visit:
 http://list.valvesoftware.com/mailman/listinfo/hlcoders


--

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



[hlcoders] bf_write and unsigned characters

2006-06-03 Thread James
--
[ Picked text/plain from multipart/alternative ]
I've been trying to output messages that contain thësê kïñd of chæråchtèrs
to allow for multiple languages in my server plugin. For example, I would
use this code to output a chat area message:
void ChatAreaMsg(int index, char *msg) {
MRecipientFilter filter;
bf_write *buffer;

filter.AddRecipient(index);

buffer =
engine-UserMessageBegin(static_castIRecipientFilter*(filter), 3);
buffer-WriteByte(0);
buffer-WriteString(msg);
buffer-WriteByte(0);
engine-MessageEnd();

return ;
}

However, when I attempt to write out a message that contains characters that
are greater than 128 (unsigned) in byte size, they get stripped. I've also
tried replacing the WriteChar() in the WriteString() function with
WriteByte() but I still get the same result. Is there any way to write these
kind of characters into a bf_write? Or is this problem occurring somewhere
else downstream where these characters may be getting stripped?
--

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



RE: [hlcoders] bf_write and unsigned characters

2006-06-03 Thread Yahn Bernier
Is your input string UTF-8 encoded ( looks like char * with high bits ) or 
Unicode 16 (two bytes per character)?

You should be able to do what you are trying to do, but you could always write 
your own version of WriteString that used the WriteBytes API instead and just 
txmit the data as raw binary.  Maybe prepend the # of bytes before the data 
gets put into the buffer.

Looking at bitbuf, there's nothing here which will strip the  128 chars:

void bf_write::WriteChar(int val)
{
WriteSBitLong(val, sizeof(char)  3);
}

bool bf_write::WriteString(const char *pStr)
{
if(pStr)
{
do
{
WriteChar( *pStr );
++pStr;
} while( *(pStr-1) != 0 );
}
else
{
WriteChar( 0 );
}

return !IsOverflowed();
}

Yahn

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James
Sent: Friday, June 02, 2006 11:56 PM
To: hlcoders@list.valvesoftware.com
Subject: [hlcoders] bf_write and unsigned characters

--
[ Picked text/plain from multipart/alternative ]
I've been trying to output messages that contain thësê kïñd of chæråchtèrs
to allow for multiple languages in my server plugin. For example, I would
use this code to output a chat area message:
void ChatAreaMsg(int index, char *msg) {
MRecipientFilter filter;
bf_write *buffer;

filter.AddRecipient(index);

buffer =
engine-UserMessageBegin(static_castIRecipientFilter*(filter), 3);
buffer-WriteByte(0);
buffer-WriteString(msg);
buffer-WriteByte(0);
engine-MessageEnd();

return ;
}

However, when I attempt to write out a message that contains characters that
are greater than 128 (unsigned) in byte size, they get stripped. I've also
tried replacing the WriteChar() in the WriteString() function with
WriteByte() but I still get the same result. Is there any way to write these
kind of characters into a bf_write? Or is this problem occurring somewhere
else downstream where these characters may be getting stripped?
--

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



Re: [hlcoders] bf_write and unsigned characters

2006-06-03 Thread John Sheu
 However, when I attempt to write out a message that contains characters that
 are greater than 128 (unsigned) in byte size, they get stripped. I've also
 tried replacing the WriteChar() in the WriteString() function with
 WriteByte() but I still get the same result. Is there any way to write these
 kind of characters into a bf_write? Or is this problem occurring somewhere
 else downstream where these characters may be getting stripped?

What's stripped?  Are they being clamped to 128?  Or is it possible
that it's being wrapped around to -127?

I've had issues before with bf_read/bf_write and casting signed/unsigned
chars.  It usually comes down to making sure that you aren't making any
unneccessary casts.

-John Sheu

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders