transform UT8 to UCS-2

落爺英雄遲暮 提交于 2019-12-24 15:19:33

问题


I have recently learned that sql server 2005 does not support UTF8:

UTF8 problem sql server

I believe it supports UCS-2 though and look for a way to transform UTF8 to UCS-2 without loss of information if possible. Is it?

Any feedback would be very much welcome. Thanks!

Christian

PS: C# preferred (-:


回答1:


It looks like you have a text file encoded in UTF-8 and you want to re-encode it to UCS-2. StreamReader and StreamWriter support encoding automatically; you supply an Encoding object in their constructors.

You should be able to:

  1. Construct a StreamReader with Encoding.UTF8
  2. Construct a StreamWriter with Encoding.Unicode
  3. Read lines from the reader and write them to the writer


来源:https://stackoverflow.com/questions/3342322/transform-ut8-to-ucs-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!