Re: Obtain Unicode value from Character Code?
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 09/10/04
- Next message: Jon Skeet [C# MVP]: "Re: Properties Retuning Arrays"
- Previous message: Dan: "Re: File.Exists question"
- In reply to: Craig Wagner: "Re: Obtain Unicode value from Character Code?"
- Next in thread: Craig Wagner: "Re: Obtain Unicode value from Character Code?"
- Reply: Craig Wagner: "Re: Obtain Unicode value from Character Code?"
- Reply: Craig Wagner: "Re: Obtain Unicode value from Character Code?"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Jon Skeet [C# MVP]: "Re: Properties Retuning Arrays"
- Previous message: Dan: "Re: File.Exists question"
- In reply to: Craig Wagner: "Re: Obtain Unicode value from Character Code?"
- Next in thread: Craig Wagner: "Re: Obtain Unicode value from Character Code?"
- Reply: Craig Wagner: "Re: Obtain Unicode value from Character Code?"
- Reply: Craig Wagner: "Re: Obtain Unicode value from Character Code?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|