At 5:57 PM -0800 2/22/07, David Glass wrote:
>2Kng??  (should be 2 Kings)
>
>Where the ?? could be anything, but most often a random(?) oriental 
>character, an empty space, or other random odd character (like a delta).
>To make things more weird, the incorrect characters change each time 
>I 'step' through lines of code.
>
>If I drill to the specific variable, I'm told the encoding is UTF-8 
>which is what I want it to be.  In this particular example the length 
>is reported as 7 and the lengthB as 14.
>
>This information does not change (the encoding is always UTF-8, and 
>the lengths don't change), and the debugger view shows the text 
>properly, but when I send the text to Drawstring  it comes out whacked.

2 Kings would only be 7 bytes in UTF8, so you do have some sort of 
encoding problem. Since your string has twice as many bytes as 
characters it may be in UTF-16 encoding, not UTF-8 as you're 
expecting.

If you set the proper encoding on data you read in from an external 
source, RB will generally handle text encodings for you automatically.

So the two suggestions are to:

1. Double check that the encoding of the source file is what you 
really think it is and make sure you're setting the strings to that 
encoding as you read them in.

2. Be very suspicious of using DefineEncoding anywhere within your 
program. Generally you shouldn't need it at all except when you're 
initially reading in the strings.

BTW The encoding of a string that you get out of an editfield might 
NOT necessarily be the same encoding as the string you initially 
wrote in. Don't assume the encoding. Just make sure it's right 
initially and then let RB do its thing when handling text strings.

Regards,
Joe Huber
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to