Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>These two are slightly different:</p> <ul> <li>Char(130) is a <a href="http://docwiki.embarcadero.com/RADStudio/en/Expressions_%28Delphi%29#Value_Typecasts" rel="noreferrer">value typecast</a> rather than a function call. An integer with value <code>130</code> is converted to a <code>Char</code> with that ordinal.</li> <li>Chr(130) is indeed a function call. It invokes the <a href="http://docwiki.embarcadero.com/RADStudio/en/Delphi_Intrinsic_Routines" rel="noreferrer">intrinsic</a> function <a href="http://docwiki.embarcadero.com/Libraries/en/System.Chr" rel="noreferrer"><code>Chr()</code></a>. </li> </ul> <p>In both pre and post Unicode versions of Delphi, you can use the <code>Char()</code> and <code>Chr()</code> versions interchangeably. However, the results differ depending on the Delphi version you use.</p> <p>For pre-Unicode Delphi, <code>Char</code> is an 8 bit ANSI character. For post-Unicode Delphi, <code>Char</code> is a 16 bit UTF-16 character.</p> <p>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 <code>Char</code> with <code>AnsiChar</code>. 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.</p> <p>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 <a href="http://www.fileformat.info/info/unicode/char/201a/index.htm" rel="noreferrer">SINGLE LOW-9 QUOTATION MARK U+201A</a>. Write it like this in Unicode Delphi:</p> <pre><code>Chr($201A) </code></pre> <p>or like this:</p> <pre><code>#$201A </code></pre> <p>or like this:</p> <pre><code>'‚' </code></pre> <p>On the other hand, perhaps you actually do want a comma, noting that <code>AnsiChar(130)</code> is not a comma but is in fact a quotation mark.</p> <p>If you want a comma (<a href="http://www.fileformat.info/info/unicode/char/002c/index.htm" rel="noreferrer">COMMA U+002C</a>), well that's easy:</p> <pre><code>Chr($002C) </code></pre> <p>or</p> <pre><code>#$002C </code></pre> <p>or</p> <pre><code>',' </code></pre> <p>Some required reading for you: <a href="http://edn.embarcadero.com/article/38980" rel="noreferrer">Delphi and Unicode by Marco Cantù</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload