These two are slightly different:
- Char(130) is a value typecast rather than a function call. An integer with value
130
is converted to aChar
with that ordinal. - Chr(130) is indeed a function call. It invokes the intrinsic function
Chr()
.
In both pre and post Unicode versions of Delphi, you can use the Char()
and Chr()
versions interchangeably. However, the results differ depending on the Delphi version you use.
For pre-Unicode Delphi, Char
is an 8 bit ANSI character. For post-Unicode Delphi, Char
is a 16 bit UTF-16 character.
Exactly how you should resolve this depends on what you are trying to achieve. If you wish to bury your head in the sand, and pretend that Unicode characters don't exist, then perhaps you want to replace all your use of Char
with AnsiChar
. And you'll also want to hope that your program is only ever run on a machine with a locale that maps character 130 onto that character. Do be aware that not all Windows ANSI locales do so.
However, I suspect that the right solution to your problem, whatever it is, will be to embrace Unicode, and use the UTF-16 encoding for that character. It is SINGLE LOW-9 QUOTATION MARK U+201A. Write it like this in Unicode Delphi:
Chr($201A)
or like this:
#$201A
or like this:
'‚'
On the other hand, perhaps you actually do want a comma, noting that AnsiChar(130)
is not a comma but is in fact a quotation mark.
If you want a comma (COMMA U+002C), well that's easy:
Chr($002C)
or
#$002C
or
','
Some required reading for you: Delphi and Unicode by Marco Cantù.