Encoding for cross-Platform DB with V4RB 1.x

Thierry Nauze ohmitou at wanadoo.fr
Mon Sep 5 18:31:29 CDT 2005



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

It works fine for me.

Regards,

--
Thierry NAUZE        Saint-Denis de la Réunion





More information about the Valentina mailing list