Re: Obtain Unicode value from Character Code?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Craig Wagner (craig_d_wagner_at_hotmail.com)
Date: 09/10/04


Date: Fri, 10 Sep 2004 08:53:58 -0700

Jon Skeet [C# MVP] <skeet@pobox.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.

We also have the font set to use to represent the character. This information is
being used to create a Word document using WordML.

It ain't my design, but it has been working pretty well until we went to
implement this new feature.

>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.

I'll give it a shot. Thanks.

---
Craig Wagner, craig.wagner(at)comcast.net
Portland, OR
"Don't ban high-performance vehicles, ban low-performance drivers!"


Relevant Pages

  • Re: Funky Error
    ... >storing arbitrary binary information, unlike character ... Storing binary data in character ... I get this error from any query that referances ... >>paticular field within one of the tables I'm working ...
    (microsoft.public.sqlserver.programming)
  • Re: Obtain Unicode value from Character Code?
    ... the database really ought to be able to know how it's stored ... The database isn't storing the ... > character, it's storing the character code (i.e. it's not storing the smart ... the encoding is subtly different though, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Funky Error
    ... The char and varchar types are not ... storing arbitrary binary information, unlike character types, which are ... Storing binary data in character types can raise ...
    (microsoft.public.sqlserver.programming)
  • Re: Funky Error
    ... The char and varchar types are not ... > storing arbitrary binary information, unlike character types, which are ... Storing binary data in character types can raise ... And I was able to query the remote server with both MSDASQL and SQLOLEDB ...
    (microsoft.public.sqlserver.programming)
  • Re: Proper Way To Store, Retrieve Text To/From PostgreSQL
    ... PostgreSQL database and have it reappear back on another page exactly ... can become the character I wish to preserve and strip the others. ... able to store these items and not munge them on me reading them back ... I fear storing the data as htmlentity, hexadecimal, or octal because ...
    (comp.lang.php)