[英]Writing UTF-8 string to socket in Java
At the moment I use 目前我使用
serverOutput = new DataOutputStream(socketCliente.getOutputStream());
and then 接着
serverOutput.write(data.getBytes());
and it works fine UNTIL I add any non standard characters (for example ñ) and then as many characters I add, that number of characters are cut from the end of the file and don't arrive. 直到我添加任何非标准字符(例如ñ),然后再添加尽可能多的字符,该字符的数量都很好,直到从文件的末尾开始切入并且不到达。
Full source code is available here in PandroidAgentTentacle.java 完整的源代码可在此处找到,PandroidAgentTentacle.java
http://pandora.svn.sourceforge.net/viewvc/pandora/trunk/pandora_agents/android/src/pandroid/agent/ http://pandora.svn.sourceforge.net/viewvc/pandora/trunk/pandora_agents/android/src/pandroid/agent/
使用DataOutputStream的好处是,您具有writeUTF方法,可以为您封装所有这些方法。
have you tried to use serverOutput.write(data.getBytes("UTF-8"));
您是否尝试过使用
serverOutput.write(data.getBytes("UTF-8"));
? ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.