Android Question Special Latin Characters in PostString

Chianca

Member
Licensed 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?
 

Chianca

Member
Licensed 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)
 

lemonisdead

Well-Known Member
Licensed 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
 
Top