iso-8859-1

Converting UTF-8 to ISO-8859-1 in Java

久未见 提交于 2019-11-27 12:00:41
问题 I am reading an XML document (UTF-8) and ultimately displaying the content on a Web page using ISO-8859-1. As expected, there are a few characters are not displayed correctly, such as “ , – and ’ (they display as ?). Is it possible to convert these characters from UTF-8 to ISO-8859-1? Here is a snippet of code I have written to attempt this: BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8")); StringBuilder sb = new StringBuilder(); String

How do I transcode a Javascript string to ISO-8859-1?

自作多情 提交于 2019-11-27 08:21:38
I'm writing a Chrome extension that works with a website that uses ISO-8859-1. Just to give some context, what my extension does is making posting in the site's forums quicker by adding a more convenient post form. The value of the textarea where the message is written is then sent through an Ajax call (using jQuery). If the message contains characters like á these characters appear as á in the posted message. Forcing the browser to display UTF-8 instead of ISO-8859-1 makes the á appear correctly. It is my understanding that Javascript uses UTF-8 for its strings, so it is my theory that if I

How do I decode mail header strings with their encoding type in them in PHP

社会主义新天地 提交于 2019-11-27 07:22:56
问题 I'm creating a small, web based, mail client in PHP and noticed that a number of email Subjects and Contents appear as follows: =?ISO-8859-1?Q?Everything_for_=A35_-_Box_Sets,_Games_?= =?ISO-8859-1?Q?and_CD_Soundtracks...hurry,_ends_soon?= =?utf-8?B?UGxheS5jb206IE9uZSBEYXkgT25seSDigJMgT3V0IG9mIHRoaXMgV29ybGQgRGVhbHMh?= =?windows-1252?Q?Jon,_delivery_on_us_&_earn_=A35_credit_or_50_prints?= Does anyone have any ideas for decoding them so they display correctly? 回答1: This is an RFC 2047 encoded

How do I write out a text file in C# with a code page other than UTF-8?

蓝咒 提交于 2019-11-27 07:22:48
I want to write out a text file. Instead of the default UTF-8, I want to write it encoded as ISO-8859-1 which is code page 28591. I have no idea how to do this... I'm writing out my file with the following very simple code: using (StreamWriter sw = File.CreateText(myfilename)) { sw.WriteLine("my text..."); sw.Close(); } using System.IO; using System.Text; using (StreamWriter sw = new StreamWriter(File.Open(myfilename, FileMode.Create), Encoding.WhateverYouWant)) { sw.WriteLine("my text..."); } An alternate way of getting your encoding: using System.IO; using System.Text; using (var sw = new

PHP source code in UTF-8 files; how to interpret properly?

白昼怎懂夜的黑 提交于 2019-11-27 03:05:42
问题 I build tools to analyze source code. Such tools have to read the source code files correctly, especially as regards character encodings. For example, "What is the precise string of bytes in a string literal?" (both PHP literals, and HTML text). My perhaps erroneous understanding is that PHP source files are 8-bit character only (that is, the PHP engine reads them that way [right]?, since they are only supposed to contain 8 bit characters). But, eight bit characters in which encoding ? (I

Convert text value in SQL Server from UTF8 to ISO 8859-1

耗尽温柔 提交于 2019-11-27 01:54:17
I have a column in SQL Server with utf8 SQL_Latin1_General_CP1_CI_AS encoding. How can I convert and save the text in ISO 8859-1 encoding? I would like to do thing in a query on SQL Server. Any tips? Olá. Gostei do jogo. Quando "baixei" até achei que não iria curtir muito I have written a function to repair UTF-8 text that is stored in a varchar field. To check the fixed values you can use it like this: CREATE TABLE #Table1 (Column1 varchar(max)) INSERT #Table1 VALUES ('Olá. Gostei do jogo. Quando "baixei" até achei que não iria curtir muito') SELECT *, NewColumn1 = dbo.DecodeUTF8String

Why does Java's String.getBytes() uses “ISO-8859-1”

自古美人都是妖i 提交于 2019-11-26 16:16:33
问题 from java.lang.StringCoding : String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; This is what is used from Java.lang.getBytes() , in linux jdk 7 I was always under the impression that UTF-8 is the default charset ? Thanks 回答1: It is a bit complicated ... Java tries to use the default character encoding to return bytes using String.getBytes(). The default charset is provided by the system file.encoding property. This is cached and there is no use in changing it via the System

MySQL - Convert latin1 characters on a UTF8 table into UTF8

走远了吗. 提交于 2019-11-26 15:48:14
Only today I realized that I was missing this in my PHP scripts: mysql_set_charset('utf8'); All my tables are InnoDB, collation "utf8_unicode_ci", and all my VARCHAR columns are "utf8_unicode_ci" as well. I have mb_internal_encoding('UTF-8'); on my PHP scripts, and all my PHP files are encoded as UTF-8. So, until now, every time I "INSERT" something with diacritics, example: mysql_query('INSERT INTO `table` SET `name`="Jáuò Iñe"'); The 'name' contents would be, in this case: Jáuò Iñe . Since I fixed the charset between PHP and MySQL, new INSERTs are now storing correctly. However, I want to

Convert utf8-characters to iso-88591 and back in PHP

淺唱寂寞╮ 提交于 2019-11-26 14:22:47
Some of my script are using different encoding, and when I try to combine them, this has becom an issue. But I can't change the encoding they use, instead I want to change the encodig of the result from script A, and use it as parameter in script B. So: is there any simple way to change a string from UTF-8 to ISO-88591 in PHP? I have looked at utf_encode and _decode, but they doesn't do what i want. Why doesn't there exsist any "utf2iso()"-function, or similar? I don't think I have characters that can't be written in ISO-format, so that shouldn't be an huge issue. Have a look at iconv() or mb

How do I transcode a Javascript string to ISO-8859-1?

牧云@^-^@ 提交于 2019-11-26 14:07:18
问题 I'm writing a Chrome extension that works with a website that uses ISO-8859-1. Just to give some context, what my extension does is making posting in the site's forums quicker by adding a more convenient post form. The value of the textarea where the message is written is then sent through an Ajax call (using jQuery). If the message contains characters like á these characters appear as á in the posted message. Forcing the browser to display UTF-8 instead of ISO-8859-1 makes the á appear