奇数字符串编码行为 [英] Odd string encoding behaviour

查看:81
本文介绍了奇数字符串编码行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到编码字符串的问题...这里是我的代码:


byte [] s = System.Text.Encoding.ASCII.GetBytes (FieldContent);


现在,这个工作正常,只要没有超过128的字节,对于

例子,一个0x99字节结果作为0x3f字节。

我知道ASCII只是7位,但我尝试了其他编码格式,

并且他们没有得到我所需要的东西.. UTF7做了与ASCII相同的事情,

UTF8为每个0x99字节提供了0xC299,而UNICODE给出了很好的结果,但是在

unicode格式中。


我做错了什么?


Miki

解决方案

好吧,我管理好了找到某种解决方案:


System.Text.Encoding e = System.Text.Encoding.GetEncoding(" iso-8859-1");

output = BitConverter.ToString(e.GetBytes(FieldContent))。重新放置(" - ","");


有没有omething等同于iso-8859-1代码页?


Miki


好吧,我设法找到某种解决方案:


System.Text.Encoding e = System.Text.Encoding.GetEncoding(" iso-8859-1");

output = BitConverter。 ToString(e.GetBytes(FieldContent))。重新放置(" - "," );


有没有相当于iso-8859-1代码页的内容?


Miki


>有没有相当于iso-8859-1代码页的东西?

1252是MS等价物(事实上它是iso-8859-1和一些额外的东西)


-

Mihai

-------------------------

将_year_替换为_以获取真实的电子邮件


I''m having a problem with encoding a string... here''s my code:

byte[] s = System.Text.Encoding.ASCII.GetBytes(FieldContent);

Now, this works fine, as long as there are no bytes that are over 128, for
example, a 0x99 byte turns out as 0x3f byte.
I know that ASCII is just 7 bits, but i tried the other encoding formats,
and they didn''t get me what i needed... UTF7 did the same thing as ASCII,
UTF8 gave 0xC299 for each 0x99 byte, and UNICODE gave good results, but in
unicode format.

What am i doing wrong?

Miki

解决方案

Well, i managed to find a solution of some sort:

System.Text.Encoding e = System.Text.Encoding.GetEncoding("iso-8859-1");
output = BitConverter.ToString(e.GetBytes(FieldContent)).Re place("-"," ");

Is there something equivalent to the iso-8859-1 codepage?

Miki


Well, i managed to find a solution of some sort:

System.Text.Encoding e = System.Text.Encoding.GetEncoding("iso-8859-1");
output = BitConverter.ToString(e.GetBytes(FieldContent)).Re place("-"," ");

Is there something equivalent to the iso-8859-1 codepage?

Miki


> Is there something equivalent to the iso-8859-1 codepage?
1252 is the MS equivalent (it is in fact iso-8859-1 with some extras)

--
Mihai
-------------------------
Replace _year_ with _ to get the real email


这篇关于奇数字符串编码行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆