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...charcodeat.asp
Any suggestions?
---
Craig Wagner, craig.wagner(at )comcast.net
Portland, OR
"Don't ban high-performance vehicles, ban low-performance drivers!" 15 9811
Hi Craig,
Didn't you try to get that char codes as "char" or "string"?
You can also try "Encoding.UTF8. GetString(...)" .
If you'll get this string then [index] should do the job.
Regards
Marcin 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...charcodeat.asp
Any suggestions? --- Craig Wagner, craig.wagner(at )comcast.net Portland, OR
"Don't ban high-performance vehicles, ban low-performance drivers!"
Hi Craig,
Didn't you try to get that char codes as "char" or "string"?
You can also try "Encoding.UTF8. GetString(...)" .
If you'll get this string then [index] should do the job.
Regards
Marcin 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...charcodeat.asp
Any suggestions? --- Craig Wagner, craig.wagner(at )comcast.net Portland, OR
"Don't ban high-performance vehicles, ban low-performance drivers!"
Craig Wagner <cr************ @hotmail.com> wrote: 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').
<snip>
Any suggestions?
I *think* you're after Encoding.Defaul t.
However, the database really ought to be able to know how it's stored
them and give you the text in Unicode. What's the type of the column,
what's the database in question, and how are you retrieving the
database?
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Craig Wagner <cr************ @hotmail.com> wrote: 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').
<snip>
Any suggestions?
I *think* you're after Encoding.Defaul t.
However, the database really ought to be able to know how it's stored
them and give you the text in Unicode. What's the type of the column,
what's the database in question, and how are you retrieving the
database?
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote: However, the database really ought to be able to know how it's stored them and give you the text in Unicode. What's the type of the column, what's the database in question, and how are you retrieving the database?
Sorry, the last bit of course should be "how are you retrieving the
value".
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote: However, the database really ought to be able to know how it's stored them and give you the text in Unicode. What's the type of the column, what's the database in question, and how are you retrieving the database?
Sorry, the last bit of course should be "how are you retrieving the
value".
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote: Craig Wagner <cr************ @hotmail.com> wrote: 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').
<snip>
Any suggestions?
I *think* you're after Encoding.Defaul t.
However, the database really ought to be able to know how it's stored them and give you the text in Unicode. What's the type of the column, what's the database in question, and how are you retrieving the database?
The database has stored the value as an integer. The database isn't storing the
character, it's storing the character code (i.e. it's not storing the smart
quote, it's storing 147 as an integer).
The database is SQL Server 2000 and my C# code is calling a stored proc that is
used to populate a DataTable.
---
Craig Wagner, craig.wagner(at )comcast.net
Portland, OR
"Don't ban high-performance vehicles, ban low-performance drivers!"
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote: Craig Wagner <cr************ @hotmail.com> wrote: 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').
<snip>
Any suggestions?
I *think* you're after Encoding.Defaul t.
However, the database really ought to be able to know how it's stored them and give you the text in Unicode. What's the type of the column, what's the database in question, and how are you retrieving the database?
The database has stored the value as an integer. The database isn't storing the
character, it's storing the character code (i.e. it's not storing the smart
quote, it's storing 147 as an integer).
The database is SQL Server 2000 and my C# code is calling a stored proc that is
used to populate a DataTable.
---
Craig Wagner, craig.wagner(at )comcast.net
Portland, OR
"Don't ban high-performance vehicles, ban low-performance drivers!"
Craig Wagner <cr************ @hotmail.com> wrote: However, the database really ought to be able to know how it's stored them and give you the text in Unicode. What's the type of the column, what's the database in question, and how are you retrieving the database?
The database has stored the value as an integer. The database isn't storing the character, it's storing the character code (i.e. it's not storing the smart quote, it's storing 147 as an integer).
The database is SQL Server 2000 and my C# code is calling a stored proc that is used to populate a DataTable.
So it's storing a character as the integer value in an ill-defined
encoding? That doesn't sound like a terribly good idea, to be honest.
Anyway, Encoding.Defaul t *might* do what you want it to, as I said
before - just put the integer value into a byte array as the sole
value, and call Encoding.GetStr ing to get the appropriate string. If
the encoding is subtly different though, you'll have problems.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dominik Jain |
last post by:
Hi!
We hope somebody can help me with the following:
We have a form through which unicode data might be submitted. We need to be
able to detect when this happens and, most importantly, we need to be able
to obtain the unicode character codes for each individual letter/symbol.
Is this possible in PHP? If so, can you please provide a short code snippet.
We looked at the mbstring extension but found nothing helpful, especially
|
by: S. |
last post by:
if in my website i am using the sgml { notation, is it accurate
to say to my users that the site uses unicode or that it requires
unicode?
is there a mathematical formula to calculate a unicode value given its
utf8 value?
Rgds,
Sam
|
by: Chris Mullins |
last post by:
I'm implementing RFC 3491 in .NET, and running into a strange issue.
Step 1 of RFC 3491 is performing a set of mappings dicated by tables B.1 and
B.2.
I'm having trouble with the following mappings though, and it seems like a
shortcoming of the .NET framework:
When I see Unicode value 0x10400, I'm supposed to map it to value 0x10428.
This list goes on (the left colulmn is the existing value, the right column
|
by: Basil |
last post by:
Hello.
I have compiler BC Builder 6.0.
I have an example:
#include <strstrea.h>
int main () {
wchar_t ff = {' s','d ', 'f', 'g', 't'};
|
by: Patrick Van Esch |
last post by:
Hello,
I have the following problem of principle:
in writing HTML pages containing ancient greek, there are two
possibilities: one is to write the unicode characters directly
(encoded as two bytes) into the HTML source, and save this source not
as an ASCII text, but as a UNICODE text file (using 16 bits per
character, also for the Western ASCII characters, which are usually
encoded as Ox00XX with XX the ASCII code) ; or to write a pure...
| |
by: Craig Wagner |
last post by:
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...
|
by: Sonu |
last post by:
Hello everyone and thanks in advance.
I have a multilingual application which has been built in MFC VC++ 6.0
(non-Unicode). It support English German Hungarian so far, which has been
fine. But now I need it to work on Russian computers and I realized that the
application should be converted to Unicode to work in Russian.
I am totally new to .NET so I'm not sure of this, but I read somewhere that
if converted my apllication to .NET...
|
by: apprentice |
last post by:
Hello,
I'm writing an class library that I imagine people from different countries
might be interested in using, so I'm considering what needs to be provided
to support foreign languages, including asian languages (chinese, japanese,
korean, etc).
First of all, strings will be passed to my class methods, some of which
based on the language (and on the encoding) might contain characters that
require more that a single byte.
|
by: Ron Garret |
last post by:
>>> u'\xbd'
u'\xbd'
>>> print _
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in
position 0: ordinal not in range(128)
>>>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |