Crosspaltform accented characters
erne
ernestogiannotta at tiscalinet.it
Sun Nov 14 14:50:10 CST 2004
Hello,
On 13 nov 2004, at 20:42, Ruslan Zasukhin wrote:
> Guys, anybody can enlighten this issue?
> German, Italian guys?!
> Please help to Leo.
>
first I must say I'm not doing Windows and I've dropped Classic
so I got no experience in cross-platform issues as regard text encoding
anyway here's what I know
RB works natively in UTF8
that means that a literal string is always UTF8
but NOT all the strings in RB are UTF8
you should NEVER assume it (I've proved it on my own skin ;-)
it depends on where they come from
(a file for example or a system function such as ParseDate)
if the encoding of the string is known however (i.e. not nil)
it's easy to get the string in whatever encoding we want
simply do s.ConvertEncoding(myPreferredEncoding)
if the string comes from Vale 1.x the encoding is unknown
so you must Define it with s.DefinEncoding(myPreferredEncoding)
you can do it because you know the encoding you used when storing that
data
I use UTF8 but have no xPlatform needs
You should use MacRoman on the Mac and Latin1 (I guess) on Win
so Valentina will know what she's doing when converting data
(Vale converts data from Mac to Win encoding on the fly to make life
easy in days before unicode but may be a big limitation, what if we use
encodings other than Roman? Vale knows how to convert them?)
trying an example:
dim e as TextEncoding
#if TargetMacOS
e = Encodings.MacRoman
#elseif TargetWin32
e = Encodings.WindowsLatin1
#endif
// store
s = EditField1.Text // this should be an UTF8 string
s = s.ConvertEncoding(e)
vField.SetString(s)
// retrieve
s = vField.GetString
s = s.DefineEncoding(e)
s = s.ConvertEncoding(Encodings.UTF8) // back to original string
HTH
Cool Runnings,
Erne.
|er| musical box
|ne| a media store
More information about the Valentina
mailing list