iso-8859-1

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

≡放荡痞女 提交于 2019-11-28 18:55:50
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 line = null; while ((line = br.readLine()) != null) { sb.append(line); } br.close(); byte[] latin1 = sb

页面传参中文参数乱码

帅比萌擦擦* 提交于 2019-11-28 14:54:41
原文引用 大专栏 https://www.dazhuanlan.com/2019/08/26/5d6336d92a92a/ 页面传参中文参数乱码 使用 request.setCharacterEncoding('utf-8'); 使用 request.getParameter("handlerType").getBytes("ISO-8859-1"),"utf-8") 接受传递的参数值 来源: https://www.cnblogs.com/petewell/p/11411023.html

Encoding UTF8 string to ISO-8859-1 String (VB.NET)

ⅰ亾dé卋堺 提交于 2019-11-28 14:03:09
I need to convert UTF8 string to ISO-8859-1 string using VB.NET. Any example? emphasized text I have tried Latin function and not runs. I receive incorrect string. My case is that I need to send SMS using API. Now I have this code: baseurl = "http://www.myweb.com/api/sendsms.php" client = New WebClient client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)") client.Encoding = System.Text.Encoding.GetEncoding("ISO-8859-1") client.QueryString.Add("user", user) client.QueryString.Add("password", pass) client.QueryString.Add("alias", myAlias)

Convert ISO-8859-1 to UTF-8 [duplicate]

扶醉桌前 提交于 2019-11-28 12:19:30
This question already has an answer here: Jquery ignores encoding ISO-8859-1 2 answers How do I convert special UTF-8 chars to their iso-8859-1 equivalent using javascript? 5 answers I am sending a HTTP request through jQuery's ajax. But the server, which I have no access, returns ISO-8859-1 and I my page is UTF-8. How can I convert the characters to be readable? For without converting appears something like: it�rio @Edit: I've tried changing the charset of ajax requests using: $.ajax({ contentType: ... }); And I tried to change the meta of the html to ISO-8859-1. @Solution: I've found the

Convert XML latin1 to UTF-8 and other way around

倖福魔咒の 提交于 2019-11-28 11:50:41
问题 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? 回答1: The fastest method, especially with large XML

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

核能气质少年 提交于 2019-11-28 09:30:36
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 presume intended to match ISO-8859-1 (-x?) [can somebody quote chapter and verse?]. That is, an umlaut is

Java InputStream encoding/charset

情到浓时终转凉″ 提交于 2019-11-27 17:38:00
问题 Running the following (example) code import java.io.*; public class test { public static void main(String[] args) throws Exception { byte[] buf = {-27}; InputStream is = new ByteArrayInputStream(buf); BufferedReader r = new BufferedReader( new InputStreamReader(is, "ISO-8859-1")); String s = r.readLine(); System.out.println("test.java:9 [byte] (char)" + (char)s.getBytes()[0] + " (int)" + (int)s.getBytes()[0]); System.out.println("test.java:10 [char] (char)" + (char)s.charAt(0) + " (int)" +

Java 字符集编码

笑着哭i 提交于 2019-11-27 15:54:25
1、NioTest13_In.txt文件内容拷贝到NioTest13_Out.txt文件中 public class NioTest13 { public static void main(String[] args) throws Exception { String inputFile = "NioTest13_In.txt"; String outFile = "NioTest13_Out.txt"; RandomAccessFile inputRandomAccessFile = new RandomAccessFile(inputFile,"r"); RandomAccessFile outputRandomAccessFile = new RandomAccessFile(outFile,"rw"); long inputLength = new File(inputFile).length(); FileChannel inputFileChannel = inputRandomAccessFile.getChannel(); FileChannel outputFileChannel = outputRandomAccessFile.getChannel(); MappedByteBuffer inputData = inputFileChannel.map

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

喜你入骨 提交于 2019-11-27 14:15:49
问题 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

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

*爱你&永不变心* 提交于 2019-11-27 13:14:58
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 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.setProperty(..) after the JVM starts. If the file.encoding property does not map to a known charset, then the