@harry: "Hi there
I am sitting with a problem that drives me mad. Hopefully someone can help:
When I write a string with german umlaut like "�ber" to a MySQL Database 
  or with a TCPSocket to a cgi-Script I get rubbish on the other side:
� comes out as two characters with ascii value 195 and 132,
� comes out as two characters with ascii value 195 and 150,
� comes out as two characters with ascii value 195 and 156,
� comes out as two characters with ascii value 195 and 159,
� comes out as two characters with ascii value 195 and 164,
� comes out as two characters with ascii value 195 and 182 and
� comes out as two characters with ascii value 195 and 188.
I have been playing around with the ConvertEncoding function already, 
but had no success.
Since I am sitting here still evaluating RB for writing an application 
that communicates with a MySQL database and a PHP application, I would 
be happy to hear your comments!
regards,
Harry."
    @thomasareed: "<quote>
It is probably already UTF8  you do not need to do further encoding. 
In fact, calling DefineEncoding on this string is probably a really bad
idea, since it is always possible it might be something else, so you'd
be telling RB the string is something that it is not.
If you want to have a consistent encoding in the database, replace this
with:
  sSql = ConvertEncoding(sSql, encodings.utf8)
This will ensure that the text being stored is in UTF8.
In the database, it is UTF8.  If you view it with a program that
assumes the system default encoding (probably MacRoman, I'd assume),
then it is of course going to display incorrectly  as you've seen
with strings like the one above.
You need to use DefineEncoding *after* you read a string from the
database.  This tells RB how to interpret the raw byte string.
-Thomas
<<url>"
    @joe: "<quote>
Those aren't ASCII values (which range from 0 to 127).  But what makes 
you think this is two characters?  More likely it's one character in 
UTF-8.
ConvertEncoding only helps with strings that already have a known 
encoding.  The problem here is that when you pull a string out of a 
MySQL database, its encoding is unknown.  So you need to use 
DefineEncoding to define what its encoding is (most likely, UTF-8).
It works just fine  RB's support for international text is 
outstanding.  But most database engines don't store the encoding 
information along with the bytes of a string, so you need to choose a 
standard encoding (UTF-8 is a good choice), convert to that when you put 
your strings in, and define as that when you pull your strings back out.  
Then everything will work fine.
Cheers,
- Joe
,.
|    Joseph J. Strout         Check out the Mac Web Directory:     |
|    <email_address>           <url>             |
`'"
    @joe: "<quote>
Actually, since he's on Windows XP, whatever he's using to view the 
database is probably assuming Windows-Latin-1.  (This is what 
Encodings.SystemDefault should give you on WinXP, BTW.)
But anyway, you're quite right, the problem there is that he's viewing 
the database with something that's not savvy to UTF-8.  If viewing with 
that other tool is important, then he could convert all his text to 
WindowsLatin1 before stuffing it into the database instead of UTF-8.  
And hope none of his end-users need to store Japanese.  :)
Cheers,
- Joe
,.
|    Joseph J. Strout         Check out the Mac Web Directory:     |
|    <email_address>           <url>             |
`'"
    @harry: "Thanks a lot for all the feedback... but... hm it is actually not what I 
am after: When I modify my SQL statements like the following, I get what 
I want:
s = rsField + 
"=REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE('" + 
EditField1.text) + 
"','�',CHAR(252)),'�',CHAR(246)),'�',CHAR(228)),'�',CHAR(196)),'�',CHAR(214)),'�',CHAR(220)),'�',CHAR(223))"
This is quite dirty, but the MySQL database I use sits on a providers 
achine where I do not have the possibility to change the encoding of the 
database (which is set to iso-8859-latin1) can't realBasic convert into 
a single bit ascii format that takes away the pain? PHP on UNIX reads 
any european character from the MySQL DB with no fuzz.
Well actually I do not feel like rewriting a huge PHP application just 
because RealBasic cannot deal with Text-Encoding.
so long,
Harry.
<quote>"
    @thomasareed: "<quote>
Yes, certainly:
  s = s.ConvertEncoding(Encodings.ISOLatin1)
(I think that ISOLatin1 is right  check the documentation for
Encodings to be sure I didn't misremember.)
Do this with any string *before* putting it into the database.  When
you pull strings out of the database, define their encoding as
ISOLatin1 using DefineEncoding.
Note, however, that thinking of this as ASCII is a *huge* mistake.  It
is not ASCII.  ASCII only deals with characters in the range 0 to 127. 
The "high ASCII" characters in ISOLatin1 are not ASCII, they're
something else.  MacRoman and other encodings interpret that range of
bytes differently.
REALbasic certainly *can* deal with text encodings.  Quite well, in
fact.  Please don't disparage the tool because you don't know how it
works.
-Thomas
<<url>"
    @harry: "<quote>
I used
sSql = ConvertEncoding(sSql, encodings.WindowsLatin1)
and I tried
sSql = ConvertEncoding(sSql, encodings.SystemDefault)
both with no effect :-(
then finally I tried
sSql = ConvertEncoding(sSql, encodings.ASCII)
and it worked!!
life can be so simple ;-)
Thanx to all helping here.
Harry."
{'source': 'USENET', 'other_information': '{"reply_count": 6, "forum_name": "comp.lang.basic.realbasic.20140806.mbox"}', 'file': 'data/output/usenet-comp.lang.parquet'}