本文介绍了确定在C#中的字符串的编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法来确定在C#中的字符串的编码?

Is there any way to determine a string's encoding in C#?

我说,我有一个文件名字符串,但UTF-16或系统默认编码,我怎么不知道这是否是连接codeD的我找到?

Say, I have a filename string, but I don't know if it is encoded in UTF-16 or the system-default encoding, how do I find out?

推荐答案

查看Utf8Checker很简单的类,它正是这种纯管理code。

Check out Utf8Checker it is simple class that does exactly this in pure managed code.http://utf8checker.codeplex.com

注意:前面已经指出,确定编码才有用字​​节流。如果你有一个字符串,它已经连接codeD沿谁已经知道或者猜到的编码以获得在首位的字符串的方式的人。

Notice: as already pointed out "determine encoding" makes sense only for byte streams. If you have a string it is already encoded from someone along the way who already knew or guessed the encoding to get the string in the first place.

这篇关于确定在C#中的字符串的编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 12:41