jjzjj

java - 将 Windows-1252 xml 文件转换为 UTF-8

是否有任何方法可以将大型XML文件(500+MB)从“Windows-1252”编码转换为java中的“UTF-8”编码? 最佳答案 当然:打开一个包裹在InputStreamReader中的FileInputStream,输入为Windows-1252打开一个包裹在OutputStreamWriter中的FileOutputStream,输出采用UTF-8编码创建一个缓冲区字符数组(例如16K)重复读入数组并写入已写入的内容:char[]buffer=newchar[16*1024];intcharsRead;while((cha

c# - 将 XmlTextReader 编码设置为 "windows-1252"

当我读取xml时,如何将XmlTextReader编码设置为“windows-1252”。我不想使用xml中的编码。XmlTextReaderxtr=newXmlTextReader(pathToXML);注意:为了保留换行符,我必须使用XmlTextReader而不是StreamReader。 最佳答案 StreamReaderreader=newSystem.IO.StreamReader(pathToXML,System.Text.Encoding.GetEncoding("Windows-1252"),true);XmlTe

.net - 识别并删除会破坏 FOR XML 的字符

创建XML时出错Msg6841,Level16,State1,Line26FORXMLcouldnotserializethedatafornode'value'becauseitcontainsacharacter(0x000C)whichisnotallowedinXML.ToretrievethisdatausingFORXML,convertittobinary,varbinaryorimagedatatypeandusetheBINARYBASE64directive.想出如何用TSQL解决这个问题我的问题是如何预防此数据通过.NETC#加载已经在做一些清理工作,例如:-删除

windows - 根据 windows 批处理文件中的代码页 1252 将字符 > 7F (127) 写入十六进制字符串

我在创建批处理文件时遇到问题。问题是我的输出批处理文件始终是UTF-8,不适用于批处理文件。输出包含é、à、Ä等变音符号,所以无论我做什么,我的批处理文件都会失败。因此我的问题是:有没有办法在我的批处理文件的命令中以某种7位表示形式写入7F(十进制127)以上的任何字符。例如。作为十六进制字符串,例如字符240的“\0xF0”或类似的东西。当然要使用win1252编码,我会以以下方式启动批处理文件:chcp1252 最佳答案 感谢dbenham,他看到了显而易见的东西。Generatenearlyanycharacter,inclu

python - 为什么 Python 3 默认读取编码为 cp1252 的文件?

做的时候:withopen('test.txt','r')asf:print(f)我得到:为什么默认是cp1252?test.txt已使用UTF8编码保存,.py脚本也已保存。 最佳答案 直接来自thedocumentationofopen:Thedefaultencodingisplatformdependent(whateverlocale.getpreferredencoding()returns),butanytextencodingsupportedbyPythoncanbeused.Seethecodecsmodulef

c# - 如何将大文件 (>1 GB) 的编码转换为 Windows 1252 而不会出现内存不足异常?

考虑:publicstaticvoidConvertFileToUnicode1252(stringfilePath,EncodingsrcEncoding){try{StreamReaderfileStream=newStreamReader(filePath);EncodingtargetEncoding=Encoding.GetEncoding(1252);stringfileContent=fileStream.ReadToEnd();fileStream.Close();//SavingfileasANSI1252Byte[]srcBytes=srcEncoding.GetB

c# - 将字符串的字符编码从 windows-1252 转换为 utf-8

我已经将Word文档(docx)转换为html,转换后的html的字符编码为windows-1252。在.Net中,对于这个1252字符编码,所有特殊字符都显示为“�”。此html显示在Rad编辑器中,如果html为Utf-8格式,则该编辑器可以正确显示。我试过下面的代码,但没有静脉Encodingwind1252=Encoding.GetEncoding(1252);Encodingutf8=Encoding.UTF8;byte[]wind1252Bytes=wind1252.GetBytes(strHtml);byte[]utf8Bytes=Encoding.Convert(win

c# - 没有可用于编码 1252 的数据 - Xamarin

我正在使用Xamarin开发Android应用程序,同时尝试将文本转换为byte[]我收到以下错误:nodataisavailableforencoding1252我的代码:byte[]mybyteA=Portable.Text.Encoding.UTF8.GetBytes(mystring);Mono.Security.Cryptography.SHA224Managedsha22=new_Mono.Security.Cryptography.SHA224Managed();byte[]hash=sha22.ComputeHash(mybyteA); 最佳

php - 将 UTF-8 转换为 ANSI (windows-1252)

我正在尝试将希伯来语字符串保存到文件中,同时对文件进行ANSI编码。恐怕所有尝试都失败了。PHP文件本身是UTF-8。所以这是我正在尝试的代码:$to_file="בדיקהאםנרשם";$to_file=mb_convert_encoding($to_file,"WINDOWS-1255","UTF-8");file_put_contents(dirname(__FILE__)."/txt/TESTING.txt",$to_file);出于某种原因,这会返回false。另一个尝试是:$to_file=iconv("UTF-8","windows-1252",$to_file);这将

php - 在 PHP 中检测正确的字符编码?

我正在尝试检测字符串的字符编码,但无法得到正确的结果。例如:$str="€‚ƒ„…";$str=mb_convert_encoding($str,'Windows-1252','HTML-ENTITIES');//Now$strshouldbeaWindows-1252-encodedstring.//Let'sdetectitsencoding:echomb_detect_encoding($str,'Windows-1252,ISO-8859-1,UTF-8');该代码输出ISO-8859-1但它应该是Windows-125