views:

175

answers:

6

In earlier Delphi versions, I could use

s:=chr(153);

to get a trademark symbol in a string. In Delphi 2010, that doesn't work any longer, perhaps to do with unicode. What is the equivalent code string to put the TM symbol into my string?

A: 
Mauro
+3  A: 

As per the Unicode code chart for "letterlike symbols", the TM symbol is Unicode U+2122. I don't know enough Delphi to know how you turn that into a character - perhaps

s := chr(8482);

? (8482 is the decimal for hex 2122.)

Alternatively, having looked at this page, you might try:

s := #$2122;
Jon Skeet
...or even S := #8482;
Andreas Rejbrand
+1  A: 

It's character U+2122 (http://www.fileformat.info/info/unicode/char/2122/index.htm). I haven't used Delphi for a long time, but before anything else you should try to enter the character directly (probably using a Character Map utility like Windows's charmap.exe or BabelMap). That's easier to read than anything else.

Philipp
+9  A: 

In D2010, I can do this:

s := '™' + chr(8482) + #8482;  // yields 3 subsequent TM symbols

Result: ™™™

Here's a good article, by Joel himself - I re-read it just today, in fact.
http://www.joelonsoftware.com/articles/Unicode.html

Chris Thornton
+7  A: 

I'm pretty sure that chr(153) is "Ö" (Code page 437), oh wait, it is "r" (EBCDIC 037).

Actually chr(153) is undefined unless you also specify the code page you are using.
Which is exactly the reason you should use Unicode.

Wikipedia has pages for most Unicode symbols, and includes the Unicode codepoint for them.

There is the plain trademark symbol having unicode codepoint U+2122 (Delphi: Chr($2122) or #$2122).
There is also the registered trademark symbol having unicode codepoint U+00AE (Delphi: Chr($00AE) or #$00AE).

The unicode site has a list of charts where you can find all symbols, but it takes time getting used how to find them (as the number of charts is a bit large).
The plain trademark symbol is part of the letterlike symbols.
The registered trademark symbol is part of the latin-1 supplement.

--jeroen

Jeroen Pluimers
A: 

To discover the Unicode codepoint for a given character, open Accessories -> System Tools -> Character Map, select a Unicode font, look for the character you need, in the lower left corner the application displays the Unicode code.

ldsandon