내 Blackberry 응용 프로그램에서 다음 메소드를 사용하여 JSON을로드 중입니다.BlockingSenderDestination.sendReceive() UTF-8 문제
private static Object loadJson(String uriStr){
Object _json = null;
Message response = null;
BlockingSenderDestination bsd = null;
try
{
bsd = (BlockingSenderDestination)
DestinationFactory.getSenderDestination
("CommAPISample", URI.create(uriStr));
if(bsd == null)
{
bsd =
DestinationFactory.createBlockingSenderDestination
(new Context("CommAPISample"),
URI.create(uriStr), new JSONMessageProcessor()
);
}
response = bsd.sendReceive();
_json = response.getObjectPayload();
}
catch(Exception e)
{
System.out.println(e.toString());
}
finally
{
if(bsd != null)
{
bsd.release();
}
}
return _json;
}
괜찮습니다. 하지만 문제는 JSON을받을 때 아랍어 문자가 정크로 표시됩니다.
(ا٠"Ø ± Ø|ØŠØ Ø§Ù"ت٠† Ù). 나는
Arabic shows corrupted in the JSON output
토론 당으로서, 나는 (내 서버 측 응용 프로그램에서) 형식 Uxxxx에 \에 아랍어 문자를 인코딩 블랙 베리 지원 양식에이 문제를 제출하고 그것을 작동했다. 하지만 지금은 서버 측 코드를 변경할 수없는 다른 사람의 JSON을 사용해야합니다.
그들은 asp.net C#을 사용하여 다음과 같은 데이터를 전송합니다. 서버가 위의 방식으로 데이터를 제공하는 경우
JsonResult result = new JsonResult();
result.ContentEncoding = System.Text.Encoding.UTF8;
result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
result.Data = “Data Object (Contains Arabic) comes here”
return result;
그래서 제 질문은, BlockingSenderDestination.sendReceive 방법은 UTF-8 데이터를 얻을 수 있습니까? 또는 비 ASCII 문자에 대해서만 \ uxxxx 인코딩 된 데이터가 필요합니다. 아니면 utf-8 데이터를 직접 사용할 수 있도록 (서버에 헤더를 보내는 등) 다른 작업을해야합니다.
디버그 모드에서 '응답'의 값을 확인합니다. 이미 정크 문자가 표시됩니다.
JSON을 제외하고는 어디에서나 아랍어를 처리 할 수 있습니다.
어제 게시 한 글 issue in Blackberry form입니다. 그러나 지금까지는 아무런 대답도하지 않습니다.
저는 블랙 베리와 자바를 처음 사용했습니다. 이것이 어리석은 질문이라면 미안하다.
미리 감사드립니다.
감사 가레스을 사용하여 문자열로 변환 –