Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using emdash (char(151)) in C# applications

2,591 views
Skip to first unread message

DarrylR

unread,
Aug 7, 2008, 11:21:48 AM8/7/08
to
Hello. I'm writing an application that needs to set the value of a string to
an emdash (-) (U+2014). I looked at the documentation on the Char structure
to see if I could find something that would accept the character code (e.g.
151 or hex 2014) and return the corresponding string, but I couldn't find
anything useful.

What am I missing?

Thanks,
Darryl R.


Martin Honnen

unread,
Aug 17, 2008, 8:16:00 AM8/17/08
to
DarrylR wrote:
> Hello. I'm writing an application that needs to set the value of a string to
> an emdash (-) (U+2014). I looked at the documentation on the Char structure
> to see if I could find something that would accept the character code (e.g.
> 151 or hex 2014) and return the corresponding string, but I couldn't find
> anything useful.

With C# you can use \u2014 in a string literal e.g.
string s = "\u2014";
Or you can use the same escape mechanism in a character literal e.g.
char c = '\u2014';
You can also cast the int value (8212 is 0x2014) to a char e.g.
char c = (char)8212;


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

0 new messages