Re: Obtain Unicode value from Character Code?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 09/10/04


Date: Fri, 10 Sep 2004 16:40:38 +0100

Craig Wagner <craig_d_wagner@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.Default *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.GetString to get the appropriate string. If
the encoding is subtly different though, you'll have problems.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Re: Determining encoding (Thai)
    ... I know the Query Analyzer will display the data ... I would expect query analyzer to get the character set right ... So, you need to find out what encoding the original uses, and then ... Data is encoded from characters to bytes and stored in the database ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: PHP & Unicode
    ... > Let's say I have a database and a php script that communicates with the ... The database has some kind of character encoding - let's say ... First off you'll need to use a character repertoire that makes sense ...
    (comp.lang.php)
  • Re: Ideas on storing and retriving files in a Windows Application
    ... files etc. 2) Because it is stored in a relational database, ... blobs takes some minor modifications other than just using SELECT blah FROM ... horror stories of people who started storing BLOB data in a db only to have ... > will open the appropiatte application to display the file and 2. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Number + 1
    ... Using the same number in a variety of databases may be a reason for storing ... incremented portion and the extended portion. ... The value for dmrdate is assigned automatically as today's date and time, ... My experience not only with my database but with other customers & ...
    (microsoft.public.access.gettingstarted)
  • Re: Image ctl causes bloat when using text field to store path/fil
    ... Are you storing the image in the database? ... it in your database or embedding it in the report and/or form. ... got the same bloating problem in a report containing the Image control. ... Compact on Close will attempt to do so while the database is use... ...
    (microsoft.public.access.tablesdbdesign)