有关手机中文问题传输的解决办法
百度广告
*
* @param value
public static void writeUnicode(final DataOutputStream out, final String value) throws ActionException {
final String unicode = StringFormatter.gbEncoding( value );
final int dataLength = data.length;
System.out.println( "Data Length is: " + dataLength );
out.writeInt( dataLength );
} catch (IOException e) {
}
--------------------------------------------------------------------------------
----------------------------------------------------------------------
----------------------------------------------------------------------
* This method will encode the String to unicode.
* @param gbString
*/
代码:--------------------------------------------------------------------------------
char utfBytes = gbString.toCharArray();
for( int byteIndex = 0; byteIndex < utfBytes.length; byteIndex ++ ) {
if( hexB.length() -1 ) {
String charStr = "";
charStr = dataStr.substring( start + 2, dataStr.length() );
charStr = dataStr.substring( start + 2, end);
char letter = (char) Integer.parseInt( charStr, 16 ); // 16进制parse整理字符串。
start = end;
return buffer;
--------------------------------------------------------------------------------
----------------------------------------------------------------------
----------------------------------------------------------------------
----------------------------------------------------------------------
代码:--------------------------------------------------------------------------------
* write the String data
* @param outData
private void writeSjis(DataOutputStream outData, String value) {
byte data = null;
data = ( value ).getBytes( "ISO8859_1" );
outData.write(data, 0, data.length);
System.out.println(" data.length: " + data.length);
} catch (Exception ex) {
ex.printStackTrace();
}
服务器端收到客户端字符流,是用下面方法将其转为UTF-8,以后的操作都是基于UTF-8编码。SQLServer可能会由于内吗不通有不同的变换,所以存取数据库是还要是具体的DB内码作相应的处理。
代码:--------------------------------------------------------------------------------
*
* @return
public static String isoToUtf( final String iso ) {
if( iso != null ) {
utfString = new String( iso.getBytes( "ISO-8859-1" ), "UTF-8" );
utfString = iso;
} else {
}
}
本方法应该不是最有效的,但是只要手机支持unicode的gb2312编码,应该都可以显示正常。
编辑推荐:
温馨提示:因考试政策、内容不断变化与调整,长理培训网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准! (责任编辑:长理培训)
点击加载更多评论>>