我在Live中有文档和文件夹,其中包含德国的特殊字符ü、ü、ü、have。我使用LiveLink API服务器版本9.2.0.0和客户端LiveLink 9.5.0.0版本的代码提取文档和文件夹名。
string encodedName = LLValueUtil.GetValue(mainLLObj, "Name").TrimEnd('.');
int charIndex = 0;
while (Array.IndexOf(WhitespaceChars, encodedName[charIndex]) >= 0) {
string replacement = System.Xml.XmlConvert.EncodeName(encodedName[charIndex].ToString());
encodedName = encodedName.Substring(0, charIndex) + replacement + encodedName.Substring(charIndex + 1);
charIndex += replacement.Length;
}
charIndex = encodedName.Length - 1;
// Replaces trailing WhitespaceChars
while (Array.IndexOf(WhitespaceChars, encodedName[charIndex]) >= 0) {
string replacement = System.Xml.XmlConvert.EncodeName(encodedName[charIndex].ToString());
string lastPart = encodedName.Substring(charIndex + 1);
encodedName = encodedName.Substring(0, charIndex) + replacement + lastPart;
charIndex = encodedName.Length - replacement.Length - lastPart.Length - 1;
}
string documentName = encodedName; // give fine File name此代码在Livelink服务器API版本9.5.0.0中运行良好。但在LiveLink API服务器版本9.7.1中不起作用。你能帮我解决这个问题吗?
发布于 2014-04-24 11:38:35
转到服务器Livelink/activink.exe的管理面板?func=admin.sysvars并设置字符集: UTF-8,代码部分更改如下
byte[] bytes = Encoding.Default.GetBytes(value);
var retValue = Encoding.UTF8.GetString(bytes);https://stackoverflow.com/questions/17962178
复制相似问题