Android Question Special Latin Characters in PostString

Chianca

Member
Licensed User
Longtime User
Hello, I'm using httputils to post data from Android to an Asp.net web service.

It's working normally, but when I have special characters in my string, on when the web service receive the data, special characters were modified to ????.

Exemple:

B4X:
                        ContentSend = ContentSend.Replace("$LAT$",Lat)
                        ContentSend= ContentSend.Replace("$LON$",Lon)
                        ContentSend= ContentSend.Replace("$CONTENT$","Localização")
                       
                        JobAtual.PostString(WS_Address,ContentSend)
                        JobAtual.GetRequest.SetContentType("text/xml")
                        JobAtual.GetRequest.SetContentEncoding("application/soap+xml; charset=utf-8")

In this code, when I post this string (ContentSend), the server receive the word "Localização" as "Localiza????o".


What can I do to fix this problem?
 

DonManfred

Expert
Licensed User
Longtime User
try to change
JobAtual.PostString(WS_Address,ContentSend)
to
B4X:
JobAtual.PostString(WS_Address,ContentSend.GetBytes("utf-8"))
 
Upvote 0

Chianca

Member
Licensed User
Longtime User
try to change

to
B4X:
JobAtual.PostString(WS_Address,ContentSend.GetBytes("utf-8"))


Not worked...

I get this error when try to compile:

java:221: error: no suitable method found for NumberToString(byte[])

method BA.NumberToString(Number) is not applicable
(actual argument byte[] cannot be converted to Number by method invocation conversion)
method BA.NumberToString(long) is not applicable
(actual argument byte[] cannot be converted to long by method invocation conversion)
method BA.NumberToString(int) is not applicable
(actual argument byte[] cannot be converted to int by method invocation conversion)
method BA.NumberToString(float) is not applicable
(actual argument byte[] cannot be converted to float by method invocation conversion)
method BA.NumberToString(double) is not applicable
(actual argument byte[] cannot be converted to double by method invocation conversion)
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
the server receive the word "Localização" as "Localiza????o".
Could it work using EncodeUrl from the StringUtils library ? Of course you would have to UrlDecode on your server
 
Upvote 0
Top