On 2006-12-18, at 12:20, [EMAIL PROTECTED]
wrote:
From: Dr Gerard Hammond <[EMAIL PROTECTED]>
Date: Mon, 18 Dec 2006 18:22:30 +1100
I use from a shared module.
Function GetStringUTF8(Extends df as DatabaseField) As String
I use a similar method in my code, but this doesn't solve the
problem. When writing the data through such an Encoding-Conversion to
the database and than read it back, it's ok "in the RB-World", but
"damaged" using native mySQL-Tools. Otherway round, inserting values
with other tools, will give nonsense when reading in.
This way you can set an Encoding, but the contained Non-US-ASCII
chars are blown away.
At 4:14 PM +1100 18/12/06, Tom Benson wrote:
I agree the REALbasic/MySQL database API is neglected, but I don't
think we're going to be offered the chance of picking up table
encodings through the standard API for a long time to come (ever...).
While RS beeing (or better trying to be) x-platform, it's even more
far away form being x-language or even straight forward unicode. If
you leave the "mainstream" functions or new stuff you're going to
find much things, where Unicode was never implemented. What I really
didn't get is, that after months (years?) delay in a new mySQL-PlugIn
it's still not unicode!
OK, after trying many combinations of DefineEncoding, Convert, ...
different Encodings ... I was real short before giving up.
Here is the solution ;-) that works for me, it's of course not the
best solution and with a further cup of coffe you'll find some
optimizations, but robust with all tested non-us-ascii chars. Far
more surprising it's not real slower than the default way of
conversion. So just for the records here a the methods
ConvertStringFromDB(text As String) String
Dim result As String
Dim i As Integer
Dim chars() As String
if DBEnconding = "UTF8" then
chars = SplitB(text,"")
for i = 0 to UBound(chars)
chars(i) = Encodings.UTF8.Chr(AscB(chars(i)))
next
result = Join(chars,"")
else
...
ConvertStringToDB(text As String) String
Dim outText, dummy As String
Dim i As Integer
Dim chars(), outChars() As String
if DBEnconding = "UTF8" then
chars = Split(text,"")
for i = 0 to UBound(chars)
if LenB(chars(i)) > 1 then
dummy = Encodings.ASCII.Chr(Asc(chars(i)))
outChars.Append(dummy)
else
outChars.Append(DefineEncoding(chars(i), Encodings.ASCII))
end if
next
outText =DefineEncoding( Join(outChars,""), Encodings.ASCII)
else
...
ciao
Thorsten
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>