Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2006 Mar : PWideChar/WideChar variables, string literals, UTF and whatnot...

www.cryer.info
Managed Newsgroup Archive

PWideChar/WideChar variables, string literals, UTF and whatnot...

Subject:PWideChar/WideChar variables, string literals, UTF and whatnot...
Posted by:"Aleksander Oven" (aleksander.ov..@email.si)
Date:Fri, 10 Mar 2006 21:58:30

I hope this isn't a completely wrong group for such questions, but I've
had some Unicode related mysteries torturing me long enough. It's time
I knew for sure...

#1. What happens with string literals located in code when they are
assigned to a PWideChar/WideString variable or passed to a function
that expects PWideChar/WideString parameter?
I mean - it compiles and runs fine even if literals contain non-ascii
characters. Well, at least on the same system it does. I'm not sure
what would happen on a system with different codepage.

#2. What goes on when I concatenate a WideString and an AnsiString
variable? What *exactly* does compiler do when it sees something like
that?

#3.a. What *exactly* does compiler do, when I assign an AnsiString
variable or function result to a WideString variable? As far as I know,
some sort of conversion takes place, based on current thread's codepage.
How would the code look, that would perform such a conversion
explicitly?

#3.b. What about the other way around? Assigning WideString to an
AnsiString? Again conversion, I know. But what would the code look like?

#4. Is there *any* way to have a string literal with non-ascii
characters in code and have it display correctly on any system?
I suspect the only way is to UTF-8 encode the string in question before
writing it in code. Would that be effectively the same as using the new
UTF features of Delphi's code editor?

I really hate being unsure about things like these...

TIA,
Aleksander Oven

Replies:

www.cryer.info
Managed Newsgroup Archive