iso-8859-1

Can nginx re-encode XML documents, or alter XML headers?

耗尽温柔 提交于 2020-01-03 03:35:07
问题 I have a problem ultimately caused by a third party XML document whose actual encoding (ISO 8859-1 or Windows 1252, can't tell) doesn't match its declared encoding (UTF-8). I'm looking for creative workarounds. We already use nginx proxies for various content, so perhaps there is a way to either: Re-encode the document contents on the fly from ISO 8859-1 to UTF-8; or Alter the document header on the fly, from UTF-8 to ISO 8859-1. Are either of these possible with nginx? If not, a similar tool

Re-encode url from utf-8 encoded to iso-8859-1 encoded

大憨熊 提交于 2020-01-02 06:01:11
问题 I have file:// links with non-english characters which are UrlEncoded in UTF-8. For these links to work in a browser I have to re-encode them. file://development/H%C3%A5ndplukket.doc becomes file://development/H%e5ndplukket.doc I have the following code which works: public string ReEncodeUrl(string url) { Encoding enc = Encoding.GetEncoding("iso-8859-1"); string[] parts = url.Split('/'); for (int i = 1; i < parts.Length; i++) { parts[i] = HttpUtility.UrlDecode(parts[i]); // Decode to string

Re-encode url from utf-8 encoded to iso-8859-1 encoded

一世执手 提交于 2020-01-02 06:00:04
问题 I have file:// links with non-english characters which are UrlEncoded in UTF-8. For these links to work in a browser I have to re-encode them. file://development/H%C3%A5ndplukket.doc becomes file://development/H%e5ndplukket.doc I have the following code which works: public string ReEncodeUrl(string url) { Encoding enc = Encoding.GetEncoding("iso-8859-1"); string[] parts = url.Split('/'); for (int i = 1; i < parts.Length; i++) { parts[i] = HttpUtility.UrlDecode(parts[i]); // Decode to string

PHP: Problems converting “’” character from ISO-8859-1 to UTF-8

ぃ、小莉子 提交于 2019-12-31 17:12:27
问题 I'm having some issues with using PHP to convert ISO-8859-1 database content to UTF-8. I am running the following code to test: // Connect to a latin1 charset database // and retrieve "Georgia O’Keeffe", which contains a "’" character $connection = mysql_connect('*****', '*****', '*****'); mysql_select_db('*****', $connection); mysql_set_charset('latin1', $connection); $result = mysql_query('SELECT notes FROM categories WHERE id = 16', $connection); $latin1Str = mysql_result($result, 0);

Python 2 assumes different source code encodings

不想你离开。 提交于 2019-12-29 09:29:06
问题 I noticed that without source code encoding declaration, the Python 2 interpreter assumes the source code is encoded in ASCII with scripts and standard input : $ python test.py # where test.py holds the line: print u'é' File "test.py", line 1 SyntaxError: Non-ASCII character '\xc3' in file test.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details $ echo "print u'é'" | python File "/dev/fd/63", line 1 SyntaxError: Non-ASCII character '\xc3' in file /dev

Java App : Unable to read iso-8859-1 encoded file correctly

好久不见. 提交于 2019-12-29 06:22:09
问题 I have a file which is encoded as iso-8859-1, and contains characters such as ô . I am reading this file with java code, something like: File in = new File("myfile.csv"); InputStream fr = new FileInputStream(in); byte[] buffer = new byte[4096]; while (true) { int byteCount = fr.read(buffer, 0, buffer.length); if (byteCount <= 0) { break; } String s = new String(buffer, 0, byteCount,"ISO-8859-1"); System.out.println(s); } However the ô character is always garbled, usually printing as a ? . I

Using .NET how to convert ISO 8859-1 encoded text files that contain Latin-1 accented characters to UTF-8

廉价感情. 提交于 2019-12-28 02:55:06
问题 I am being sent text files saved in ISO 88591-1 format that contain accented characters from the Latin-1 range (as well as normal ASCII a-z, etc.). How do I convert these files to UTF-8 using C# so that the single-byte accented characters in ISO 8859-1 become valid UTF-8 characters? I have tried to use a StreamReader with ASCIIEncoding, and then converting the ASCII string to UTF-8 by instantiating encoding ascii and encoding utf8 and then using Encoding.Convert(ascii, utf8, ascii.GetBytes(

JAVA字符编码系列二:Unicode,ISO-8859,GBK,UTF-8编码及相互转换[引]

安稳与你 提交于 2019-12-28 00:49:14
引自 http://blog.csdn.net/qinysong/archive/2006/09/05/1179489.aspx 1、函数介绍 在Java中,字符串用统一的Unicode编码,每个字符占用两个字节,与编码有关的两个主要函数为: 1)将字符串用指定的编码集合解析成字节数组,完成Unicode-〉charsetName转换 public byte[] getBytes(String charsetName) throws UnsupportedEncodingException  2)将字节数组以指定的编码集合构造成字符串,完成charsetName-〉Unicode转换 public String(byte[] bytes, String charsetName) throws UnsupportedEncodingException 2、Unicode与各编码之间的直接转换 下面以对中文字符串"a中文"的编码转换为例,来了解各种编码之间的转换 1)Unicode和GBK 测试结果如下,每个汉字转换为两个字节,且是可逆的,即通过字节可以转换回字符串 String - GBK 〉 ByteArray:\u0061\u4E2D\u6587(a中文)-〉0x61 0xD6 0xD0 0xCE 0xC4 ByteArray - GBK 〉 String:0x61 0xD6

ISO-8859-1 encoded strings out of /into JSON in Java

允我心安 提交于 2019-12-24 16:44:12
问题 My application has a Java servlet that reads a JSONObject out of the request and constructs some Java objects that are used elsewhere. I'm running into a problem because there are strings in the JSON that are encoded in ISO-8859-1. When I extract them into Java strings, the encoding appears to get interpreted as UTF-16. I need to be able to get the correctly encoded string back at some point to put into another JSON object. I've tried mucking around with ByteBuffers and CharBuffers, but then

CSV from UTF8 to ISO-8859-1

时光毁灭记忆、已成空白 提交于 2019-12-24 10:42:17
问题 i am trying to modify my CSV export. But it wont convert / save my CSV from UTF-8 to ISO-8859-1 Any Ideas what i have made wrong, please? Actually since modifying this, i get a empty CSV File... (php 7.0.x) function my_GenerateCSV($prefix, $csvarray, $getMonth){ ### Generate CSV File from CSVArray if ($prefix == 'sepa'){ $date = '-'.getTodaysDate(); } $month = $getMonth; $filename = 'private/'.$prefix.'-'.$month.$date.'.csv'; $fp = fopen(ROOTDIR . '/'.$filename, 'w'); foreach ($csvarray as