single byte characters ? how many bytes for 37 characters ? - Nicholas Paldino [.NET/C# MVP] |
05-Jul-07 12:39:08
|
bitshift,
I don't know of any encoding that is going to produce those numbers of
bytes when converting.
Is the field in SQL Server a text field, or is it a char/varchar field?
If it is a text field, then you probably shouldn't have this problem.
My guess is that this is a char field which has a fixed length of 2224,
and that is why the string is that long. If you want the field in the
database to not have a fixed length, then the column has to be a varchar
field.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com |
 |
| |
single byte characters ? how many bytes for 37 characters ? - Peter Duniho |
05-Jul-07 01:28:20
|
Well, a "char" in C# is a Unicode character, with 2 bytes. That said,
that wouldn't explain a length of 2224 bytes for a 37 character string. I
agree with Nicholas that it's likely what you're getting from the SQL
database isn't really a character string only 37 characters long.
Pete |
 |
| |
single byte characters ? how many bytes for 37 characters ? - Ignacio Machin \( .NET/ C# MVP \) |
05-Jul-07 02:42:19
|
Hi,
I addition to the other posts, post here your field definition and the code
you are using. |
 |
| |
single byte characters ? how many bytes for 37 characters ? - bitshift |
05-Jul-07 04:22:38
|
Yes, the field this string is coming from is a text column. After stepping
through a few more times, I found out I was getting an exception. After
pulling the string from the row, I was trying to decode it from base64, but
if this was an invalid image data, it would bomb. So now im checking the
length of the string first, instead of simply checking my byte array length. |
 |
| |