我试图与UTF-8号编码书写XML文件,而原始拼法则可能具有诸如黑白等无效特性,因此,需要将这些无效性质改变为有效性质。
我知道,有一种编码方法,例如,特征a
,将其改为特性类别á
。
我正试图用C#but,即没有结果。 我正在使用编码。 UTF8功能,但仅以ema性质(即:a)或某种特性结束? 性质。
因此,你们是否知道,用C#来消除这种性质变化的正确方式?
感谢你们的时间和帮助:
当地雇员
我试图与UTF-8号编码书写XML文件,而原始拼法则可能具有诸如黑白等无效特性,因此,需要将这些无效性质改变为有效性质。
我知道,有一种编码方法,例如,特征a
,将其改为特性类别á
。
我正试图用C#but,即没有结果。 我正在使用编码。 UTF8功能,但仅以ema性质(即:a)或某种特性结束? 性质。
因此,你们是否知道,用C#来消除这种性质变化的正确方式?
感谢你们的时间和帮助:
当地雇员
甲并非“无效”性质。 该公司有UTF-8编码(195和161条),Nick是正确的,如果你正确构造一切,就会透明。
你可以使用任何一种方法。
下面,在C#中,你可以采用四种方式将XML编码为:
很显然,它运作良好。 注:Replace(&”、“&>>>
必须首先替换,以便我们不取代其他已经越狱的人。
string xml = "<node>it s my "node" & i like it<node>";
encodedXml = xml.Replace("&","&").Replace("<","<").Replace(">",">").Replace(""", """).Replace(" ", "'");
// RESULT: <node>it's my "node" & i like it<node>
用于编码超文本,但超文本是XML的一种形式,这样我们也可以使用。 大部分用于伙伴关系。 NET指。 注:HtmlEncode do NOT encode ́trophes( )。
string xml = "<node>it s my "node" & i like it<node>";
string encodedXml = HttpUtility.HtmlEncode(xml);
// RESULT: <node>it s my "node" & i like it<node>
在Windows表格或Console,我使用这种方法。 如果没有其他东西,它就拯救了我,包括该制度。 我的项目中的网络参考资料,并包含所有5个术语。
string xml = "<node>it s my "node" & i like it<node>";
string encodedXml = System.Security.SecurityElement.Escape(xml);
// RESULT: <node>it's my "node" & i like it<node>
利用XmlTextWriter,你不必担心,因为必要时会越出果园。 例如,从属性来看,它只是从外逃,而在代谢价值中,它就没有逃避外逃。
string xml = "<node>it s my "node" & i like it<node>";
using (XmlTextWriter xtw = new XmlTextWriter(@"c:xmlTest.xml", Encoding.Unicode))
{
xtw.WriteStartElement("xmlEncodeTest");
xtw.WriteAttributeString("testAttribute", xml);
xtw.WriteString(xml);
xtw.WriteEndElement();
}
// RESULT:
/*
<xmlEncodeTest testAttribute="<node>it s my "node" & i like it<node>">
<node>it s my "node" & i like it<node>
</xmlEncodeTest>
*/
private static string Escape(string content)
{
var sb = new StringBuilder();
var settings = new XmlWriterSettings
{
ConformanceLevel = ConformanceLevel.Fragment
};
using (var xmlWriter = XmlWriter.Create(sb, settings))
xmlWriter.WriteString(content);
return sb.ToString();
}
This is exactly what you need: (found at http://www.codeproject.com/Articles/20255/Full-HTML-Character-Encoding-in-C)
//for example this transforms "čas" to "čas"
public static string HtmlEncode(string text)
{
char[] chars = HttpUtility.HtmlEncode(text).ToCharArray();
StringBuilder result = new StringBuilder(text.Length + (int)(text.Length * 0.1));
foreach (char c in chars)
{
int value = Convert.ToInt32(c);
if (value > 127)
result.AppendFormat("&#{0};", value);
else
result.Append(c);
}
return result.ToString();
}
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...