C
Craig Wagner
I have a situation where I have a series of character codes stored in the
database. In some cases they are the ASCII value of the character, in other
cases they are the > 127 character code value that you use in combination with
the ALT key to enter special characters into a document (e.g. ALT+0147 and
ALT+0148 get you 'smart quotes').
I'm trying to figure out how (or if it's possible) to obtain the Unicode
equivalent of the character code.
I've tried several variations of the following but so far none of them have
worked:
byte charCode = // get value from datatable
Encoding.ASCII.GetString( new byte [] { charCode } );
I also tried simply casting the charCode as a char, but of course that results
in a character using the charCode as a Unicode value, which gets me the wrong
character.
I found an example in JScript that does exactly what I want, but I'm writing in
C#. I only bring this up because it shows me that what I want to do is at least
possible, which leads me to believe there must be a way to do it.
Basically, I'm looking for an equivalent to the JScript charCodeAt method:
http://msdn.microsoft.com/library/en-us/jscript7/html/jsmthcharcodeat.asp
Any suggestions?
database. In some cases they are the ASCII value of the character, in other
cases they are the > 127 character code value that you use in combination with
the ALT key to enter special characters into a document (e.g. ALT+0147 and
ALT+0148 get you 'smart quotes').
I'm trying to figure out how (or if it's possible) to obtain the Unicode
equivalent of the character code.
I've tried several variations of the following but so far none of them have
worked:
byte charCode = // get value from datatable
Encoding.ASCII.GetString( new byte [] { charCode } );
I also tried simply casting the charCode as a char, but of course that results
in a character using the charCode as a Unicode value, which gets me the wrong
character.
I found an example in JScript that does exactly what I want, but I'm writing in
C#. I only bring this up because it shows me that what I want to do is at least
possible, which leads me to believe there must be a way to do it.
Basically, I'm looking for an equivalent to the JScript charCodeAt method:
http://msdn.microsoft.com/library/en-us/jscript7/html/jsmthcharcodeat.asp
Any suggestions?