我正在尝试将表情符号发送到我的网络服务但是我收到以下错误:
java.lang.IllegalArgumentException:非法字符(d83d)at org.kxml2.io.KXmlSerializer.reportInvalidCharacter(KXmlSerializer.java:144) 在org.kxml2.io.KXmlSerializer.writeEscaped(KXmlSerializer.java:130) 在org.kxml2.io.KXmlSerializer.text(KXmlSerializer.java:536)at org.ksoap2.serialization.DM.writeInstance(DM.java:68)at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:656) 在 org.ksoap2.serialization.SoapSerializationEnvelope.writeProperty(SoapSerializationEnvelope.java:649) 在 org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:595) 在 org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:573) 在 org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:658) 在 org.ksoap2.serialization.SoapSerializationEnvelope.writeBody(SoapSerializationEnvelope.java:555) 在org.ksoap2.SoapEnvelope.write(SoapEnvelope.java:205)at at org.ksoap2.transport.Transport.createRequestData(Transport.java:134) 在 org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:149) 在 org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118) 在 org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:113) 在corcanoe.gps.tracker.MyClass.MyFunction(MyClass.java:708)
这是我用于MyClass.MyFunction()的代码:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("MyText", MyText); //MyText has emoticons
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SOAP_VERSION);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope); //I get the error here
Object result = envelope.getResponse();
String resultData = result.toString();
return resultData;
它适用于一些像☺这样的简单表情符号,但它不适用于哭泣或大笑等新功能。所以,问题是,如何正确序列化?