iso-8859-1

How to get json_encode() to work with ISO-8859-1 (åäö)

血红的双手。 提交于 2019-12-01 03:10:22
json_encode() wont work for me when I'm using åäö. Why? And how can I get it to work? The php : echo json_encode($arr); The javascript : var theResponse = JSON.parse(xmlHttp.responseText); When I alert() the response, and the response contains å, ä or ö, the response is = NULL Please, help me out... It says in the json_encode() documentation : This function only works with UTF-8 encoded data. You should convert it to utf-8 with iconv or mbstring first. As Greg mentioned, I had to encode åäö to UTF-8 . But I did't use iconv or mbstring. When I utf8_encode() all values before putting the values

 enconding issue

空扰寡人 提交于 2019-11-30 18:54:21
I'm developing a website using PHP and these strange chars "" appears in my page, right on the top of it. My code is this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><?php echo '';?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> But when I see the source code in the browser, it shows this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www

HTML entities and charset in IE

眉间皱痕 提交于 2019-11-30 07:45:09
I am displaying html entity ✓ (a check mark: ✓) in an html document that uses iso-8859-1 for the character set. In Firefox, it displays as a check mark. In IE, it displays as a square box. Switching to UTF-8 doesn't seem to make a difference. Is there a reliable way to display these entities in IE 6 & 7 without using images? Square means that the font used does not have the glyph for that character. Unfortunately, there are not many fonts containing that character, and none of them is present by default on all Windows machines (and even less on non-Windows ones) The most likely fonts to be

Convert XML latin1 to UTF-8 and other way around

夙愿已清 提交于 2019-11-29 18:13:24
I am trying to convert an XML file from Latin1 to UTF-8 and the other way around. I have been doing some tests, but I fail to succeed this. I'm using Get-Content C:\inputfile.xml | Set-Content -Encoding utf8 C:\outputfile.xml But this is not converting anything. So I tried to give the encoding in the Get-Content , but Latin1 is not recognized in PowerShell (or that's what the error message is telling me). What's the best way to get this? The fastest method, especially with large XML files, is to use .NET System.IO.File class. Use ReadAllText with explicitly provided Latin-1 encoding: [IO.File]

Python 2 assumes different source code encodings

拜拜、爱过 提交于 2019-11-29 16:51:58
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/fd/63 on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details and it

How to convert mysql latin1 to utf8

久未见 提交于 2019-11-29 14:18:20
问题 I inherited a web system that I need to develop further. The system seems to be created by someone who read two chapters of a PHP tutorial and thought he could code... So... the webpage itself is in UTF8 and displays and inputs everything in it. The database tables have been created with UTF8 character set. But, in the config, there is "SET NAMES LATIN1". In other words, UTF8 encoded strings are populated into the database with forced latin1 coding. Is there a way to convert this mess to

HTML entities and charset in IE

血红的双手。 提交于 2019-11-29 09:36:24
问题 I am displaying html entity ✓ (a check mark: ✓) in an html document that uses iso-8859-1 for the character set. In Firefox, it displays as a check mark. In IE, it displays as a square box. Switching to UTF-8 doesn't seem to make a difference. Is there a reliable way to display these entities in IE 6 & 7 without using images? 回答1: Square means that the font used does not have the glyph for that character. Unfortunately, there are not many fonts containing that character, and none of them is

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

左心房为你撑大大i 提交于 2019-11-29 04:35:45
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 have read around the subject (and learnt a little on the way) e.g. http://www.joelonsoftware.com

JSP中request.getParameter()乱码问题

二次信任 提交于 2019-11-29 00:44:43
【转】JSP中request.getParameter()乱码问题 博客分类: java中的字符编码 第一,存文件必须以一种编码存;读文件也必须以一种编码读,如不特别设置,去系统默认的编码,中文windows为GBK编码。 从.java->.class过程是,先编写.java文件并按莫种编码方式保存,然后用javac方法编译此文件,注意如.java没按系统默认编码保存则要带encoding参数指明实际编码,否则出错,生成的.class文件存为系统默认编码。 从.jsp->.java->.class,先存为某种编码的.jsp文件,然后tomcat根据pageEncoding读取并转化为servlet存为系统默认编码,然后同上面.java->.class过程。 第二,IDE的encoding为对系统下文件打开的解码方式或保存的编码方式。特例:如果.jsp文件有<%@ page language="java" pageEncoding="UTF-8"%>,则eclipse会自动存为UTF-8方式,不管eclipse的encoding是什么,这也是eclipse的聪明之处。 第三, pageEncoding="UTF-8"表示此文件的编码方式,必须与此文件存储方式一致(所以eclipse会首选根据它来存文件),tomcat根据这个来读此.jsp文件并编译为servlet。

file_get_contents() converts UTF-8 to ISO-8859-1

為{幸葍}努か 提交于 2019-11-28 22:08:52
I am trying to get search results from yahoo.com . But file_get_contents() converts UTF-8 charset (charset, that yahoo uses) content to ISO-8859-1. Try: $filename = "http://search.yahoo.com/search;_ylt=A0oG7lpgGp9NTSYAiQBXNyoA?p=naj%C5%A1%C5%A5astnej%C5%A1%C3%AD&fr2=sb-top&fr=yfp-t-701&type_param=&rd=pref"; echo file_get_contents($filename); Scripts as header('Content-Type: text/html; charset=UTF-8'); or <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> or $er = mb_convert_encoding($filename , 'UTF-8'); or $s2 = iconv("ISO-8859-1","UTF-8",$filename ); or echo utf8_encode