Encoding for cross-Platform DB with V4RB 1.x

Frank Bitterlich bitterlich at gsco.de
Mon Sep 5 16:57:35 CDT 2005


Hi Thierry,

thanks for the answer. Unfortunately, the part I'm having problems  
with is the SQLSelect.

Try this (in a DB populated with MacRoman data):

>   curseur=db.SQLSelect( enCode("SELECT valeur FROM prefs WHERE nom  
> ='déjà vú'"), ..., ..., ... )

(Sorry if I got the accents wrong :)

On the Mac, it works. On Windows, it doesn't; regardless if I use  
WindowsLatin1, MacRoman, or UTF-8 as the encoding for the SQLSelect()  
statement. If I do a "select * from ...", I get the correct results  
(Valentina even converts it to UTF8 or WindowsLatin1 for me, even  
though I have added the data as MacRoman).

So the real question is: Which Encoding to use for the SQLSelect()  
statement on Windows, when the database was created on the Mac?

And: has the "inNativeOS" argument of the VDatabase.Create()  
statement something to do with this?

BTW, I think you can omit the "#if TargetWin..." clause if you just  
use Encodingss.SystemDefault (which is MacRoman on the Mac and  
WindowsLatin1 on Win32).

Thanks,
    Frank+++


Am 05.09.2005 um 16:31 schrieb Thierry Nauze:

>
>
> Le 5 sept. 05 à 18:09, Frank Bitterlich a écrit :
>
>
>> Hi,
>>
>> I have a scenario where I create a Database from a Mac app for use  
>> on Windows and Mac. Which encoding should I use when I add data  
>> and query later? I tried UTF-8, but that doesn't seem to work. If  
>> I use MacRoman, it works on the Mac, but I can't select later on  
>> Windows.
>>
>> Which text encoding is the right one?
>>
>
>
>
> Function enCode(s as string) as string
>   #if TargetWin32
>     return  convertEncoding(t,encodings.windowsLatin1)
>   #else
>  return convertEncoding(t,encodings.MacRoman)
>   #endif
> End Function
>
> Function deCode(s as string) as string
>   #if TargetWin32
>    return convertEncoding(defineEncoding 
> (s,encodings.windowsLatin1),encodings.UTF8)
>   #else
>   return convertEncoding(defineEncoding 
> (s,encodings.MacRoman),encodings.UTF8)
>   #endif
> End Function
>
>
>
>   curseur=db.SQLSelect( enCode("SELECT valeur FROM prefs WHERE nom  
> ='nimportequoi'"), ..., ..., ... )
>
>   if curseur<>nil then
>   maValeur= deCode(curseur.field(1).getString)
>   end

-- 

Günter Schmidt & Co. oHG
Frank Bitterlich             eMail: bitterlich at gsco.de
Schlosserstr. 4              WWW:   http://www.gsco.de/
D-60322 Frankfurt            Tel.:  069 / 156809-29
GERMANY                      Fax:   069 / 156809-28




More information about the Valentina mailing list