|
Originally posted by hypenozys:
| I have a program that does a lot with strings, and is required to work everywhere in the world, so also in Asia for example. What is the way to do this in Delphi? Only use the Ansi... string functions? If i understand correctly the default string type should support this. If i write code like
var SomeString: string; SomeChar: char; begin if SomeString[1] = SomeChar then blabla Does this work in other locales? If not how to do this? How do i get the length of a string (in characters)?
If i understand correctly the only reason Delphi is not 100% unicode is because it would break Win9x compatibility. Please go ahead Borland! I don't want to worry about this crap... |
|
|
|
"What is the way to do this in Delphi? Only use the Ansi... string functions? If i understand correctly the default string type should support this."
The Ansi functions are NOT the way you want to do things. That only supports the 256 characters of the current codeset on the computer.
What you may understand is that the String type is actually recast as either AnsiString or WideString (AnsiString by default) depending on compiler settings, and so can be switched at the compiler level. You have to code carefully to make sure that switching back and forth works correctly.
What you want to do (from what I gather you're asking) is to stick with WideString and its functions, so that you always work in Unicode. That will allow all text to work globally.
"How do i get the length of a string (in characters)?"
use Length(), either way you go.
"If i understand correctly the only reason Delphi is not 100% unicode is because it would break Win9x compatibility. Please go ahead Borland! I don't want to worry about this crap... "
Borland doesn't do it because it would be very time consuming and expensive, with little payback. .NET already handles this, so if you want to use Delphi, you use Delphi for .NET, and you've got the future covered.
Delphi for Win32 is very Unicode compliant, however. To go the extra mile, I suggest the TNT Unicode controls at http://www.tntware.com/delphicontrols/unicode/
I've used them myself, and they work great.
-- joshua
Joshua Delahunty