Re: Byte size of characters when encoding
From: Vladimir (xozar_at_tut.by)
Date: 07/09/04
- Next message: Klaus H. Probst: "Re: Reference vb.net dll in a VB6 application"
- Previous message: One Handed Man \( OHM - Terry Burns \): "Re: How To: Colour Flash TextBox background?"
- In reply to: mikeb: "Re: Byte size of characters when encoding"
- Next in thread: mikeb: "Re: Byte size of characters when encoding"
- Reply: mikeb: "Re: Byte size of characters when encoding"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 10 Jul 2004 01:01:17 +0300
> > Method UnicodeEncoding.GetMaxByteCount(charCount) returns charCount * 2.
> > Method UTF8Encoding.GetMaxByteCount(charCount) returns charCount * 4.
> >
> > But why that?
>
> Strings in .NET are already Unicode encoded. So if you encode the
> string to an array of bytes, you get bytes per character.
>
> However, for UTF8 encoding a single Unicode character can be encoded
> using up to 4 bytes in the worst case. charCount*4 is just a worst case
> scenario if the string happened to contain only characters that required
> 4 byte encoding.
Do you want to say that two instances of struct Char in UTF-8 can occupy 8
bytes?
- Next message: Klaus H. Probst: "Re: Reference vb.net dll in a VB6 application"
- Previous message: One Handed Man \( OHM - Terry Burns \): "Re: How To: Colour Flash TextBox background?"
- In reply to: mikeb: "Re: Byte size of characters when encoding"
- Next in thread: mikeb: "Re: Byte size of characters when encoding"
- Reply: mikeb: "Re: Byte size of characters when encoding"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|