iso-8859-1

Why is conversion from UTF-8 to ISO-8859-1 not the same in Windows and Linux?

回眸只為那壹抹淺笑 提交于 2019-12-02 04:43:16
问题 I have the following in code to convert from UTF-8 to ISO-8859-1 in a jar file and when I execute this jar in Windows I get one result and in CentOS I get another. Might anyone know why? public static void main(String[] args) { try { String x = "Ä, ä, É, é, Ö, ö, Ãœ, ü, ß, «, »"; Charset utf8charset = Charset.forName("UTF-8"); Charset iso88591charset = Charset.forName("ISO-8859-1"); ByteBuffer inputBuffer = ByteBuffer.wrap(x.getBytes()); CharBuffer data = utf8charset.decode

How to encode a string in UTF-8 from a ResultSet encoded in latin1

…衆ロ難τιáo~ 提交于 2019-12-02 03:21:13
问题 I'm writing an application (uses UTF-8) that need read/write to a second database of an external application (uses ISO-8859-1). try { // data in latin1 String s = rs.getString("sAddrNameF"); System.out.println(s); // shows "Adresse d'exp�dition" byte[] data = s.getBytes(); String value = new String(data, "UTF-8"); System.out.println("data in UTF8: " + value); // The expected result should be "Adresse d'expédition" } catch (UnsupportedEncodingException e) { e.printStackTrace(); } This code is

Why is conversion from UTF-8 to ISO-8859-1 not the same in Windows and Linux?

帅比萌擦擦* 提交于 2019-12-02 02:15:48
I have the following in code to convert from UTF-8 to ISO-8859-1 in a jar file and when I execute this jar in Windows I get one result and in CentOS I get another. Might anyone know why? public static void main(String[] args) { try { String x = "Ä, ä, É, é, Ö, ö, Ü, ü, ß, «, »"; Charset utf8charset = Charset.forName("UTF-8"); Charset iso88591charset = Charset.forName("ISO-8859-1"); ByteBuffer inputBuffer = ByteBuffer.wrap(x.getBytes()); CharBuffer data = utf8charset.decode(inputBuffer); ByteBuffer outputBuffer = iso88591charset.encode(data); byte[] outputData = outputBuffer.array();

How to encode a string in UTF-8 from a ResultSet encoded in latin1

℡╲_俬逩灬. 提交于 2019-12-02 01:14:19
I'm writing an application (uses UTF-8) that need read/write to a second database of an external application (uses ISO-8859-1). try { // data in latin1 String s = rs.getString("sAddrNameF"); System.out.println(s); // shows "Adresse d'exp�dition" byte[] data = s.getBytes(); String value = new String(data, "UTF-8"); System.out.println("data in UTF8: " + value); // The expected result should be "Adresse d'expédition" } catch (UnsupportedEncodingException e) { e.printStackTrace(); } This code is not working, I also still need do the opposite conversion (writing on the database). If anybody know an

new String(str.getBytes("iso8859-1"), "UTF-8");

梦想的初衷 提交于 2019-12-01 21:04:17
1.编码基础知识 最早的编码是iso8859-1,和ascii编码相似。但为了方便表示各种各样的语言,逐渐出现了很多标准编码,重要的有如下几个。 1.1. iso8859-1 通常叫做Latin-1 属于单字节编码,最多能表示的字符范围是0-255,应用于英文系列。比如,字母a的编码为0x61=97。 很明显,iso8859-1编码表示的字符范围很窄,无法表示中文字符。但是,由于是单字节编码,和计算机最基础的表示单位一致,所以很多时候,仍旧使用iso8859-1编码来表示。而且在很多协议上,默认使用该编码。比如,虽然"中文"两个字不存在iso8859-1编码,以gb2312编码为例,应该是"d6d0 cec4"两个字符(java字符占2个字节),使用iso8859-1编码的时候则将它拆开为4个字节来表示:"d6 d0 ce c4"(事实上,在进行存储的时候,也是以字节为单位处理的)。而如果是UTF编码,则是6个字节"e4 b8 ad e6 96 87"。很明显,这种表示方法还需要以另一种编码为基础。 2.2. GB2312/GBK 这就是汉字的国标码,专门用来表示汉字,是双字节编码,而英文字母和iso8859-1一致(兼容iso8859-1编码)。其中gbk编码能够用来同时表示繁体字和简体字,而gb2312只能表示简体字,gbk是兼容gb2312编码的。 1.3 unicode

数据库测试(残稿)

情到浓时终转凉″ 提交于 2019-12-01 20:40:31
package Student; import java.sql.Connection; import java.sql.DriverManager; public class DBUtil { public static String db_url = "jdbc:mysql://localhost:3306/student?characterEncoding=utf8"; public static String db_user = "root"; public static String db_pass = "密码"; public static Connection getConn () { Connection conn = null; try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(db_url, db_user, db_pass); } catch (Exception e) { e.printStackTrace(); } return conn; } } StudentOperate.java package Student; import java.io.IOException; import java.sql.Connection; import

数据库连接:学生信息管理系统

风流意气都作罢 提交于 2019-12-01 20:37:21
package Student; import java.sql.Connection; import java.sql.DriverManager; public class DBUtil { public static String db_url = "jdbc:mysql://localhost:3306/student?characterEncoding=utf8"; public static String db_user = "root"; public static String db_pass = "xjmwan1314"; public static Connection getConn () { Connection conn = null; try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(db_url, db_user, db_pass); } catch (Exception e) { e.printStackTrace(); } return conn; } } StudentOperate.java package Student; import java.io.IOException; import java.sql.Connection;

Spring MVC用户注册和登录示例

半世苍凉 提交于 2019-12-01 15:17:02
原文地址: https://dzone.com/articles/spring-mvc-example-for-user-registration-and-login-1?edition=274902&utm_source=Daily%20Digest&utm_medium=email&utm_campaign=dd%202017-03-04 本文是使用几种Web开发语言和数据库设置用户注册和登录的分步指南。 通过 Ranjith Sekar · 3月03,17 · Web Dev Zone 本文是使用以下工具和技术的用户注册和登录的分步指南。 Spring框架(Core,MVC和JBDC) 2. Java 1.8 3.Maven 3.3.9 4. Eclipse IDE(Mars2) 5. MySQL 5.1 步骤1:创建Maven项目 使用Eclipse IDE,通过选择Web Archetype创建Maven项目。 步骤2:更新Pom.xml 更新你的maven依赖。 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0

Convert character from UTF-8 to ISO-8859-1 manually

笑着哭i 提交于 2019-12-01 10:39:26
I have the character "ö". If I look in this UTF-8 table I see it has the hex value F6 . If I look in the Unicode table I see that "ö" has the indices E0 and 16 . If I add both I get the hex value of the code point of F6 . This is the binary value 1111 0110 . 1) How do I get from the hex value F6 to the indices E0 and 16 ? 2) I don't know how to come from F6 to the two bytes C3 B6 ... Because I didn't got the results I tried to go the other way. "ö" is represented in ISO-8859-1 as "ö". In the UTF-8 table I can see that "Ã" has the decimal value 195 and "¶" has the decimal value 182 . Converted

WCF Exception: Text Message Encoding and ISO-8859-1 Encoding [duplicate]

不打扰是莪最后的温柔 提交于 2019-12-01 04:37:55
Possible Duplicate: Calling a webservice that uses ISO-8859-1 encoding from WCF I am trying to consume an external Web Service (the web service has PHP implementation) using VS 2008, .net 3.5, WCF( Environment : Windows XP and VS 2008). I add Service Reference to Web Service, VS generates WCF Proxy. Binding is basicHttpBinding. I call to method in Web Service, using Proxy, then I started getting a ProtocolException, I received the following error message : System.ServiceModel.ProtocolException: The content type text/xml; charset=ISO-8859-1 of the response message does not match the content