Android Question Special Latin Characters in PostString

Discussion in 'Android Questions' started by Chianca, Jun 15, 2015.

  1. Chianca

    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:

    Code:
    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?
     
  2. DonManfred

    DonManfred Expert Licensed User

    try to change
    to
    Code:
    JobAtual.PostString(WS_Address,ContentSend.GetBytes("utf-8"))
     
  3. Chianca

    Chianca Member Licensed User


    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)
     
  4. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Could it work using EncodeUrl from the StringUtils library ? Of course you would have to UrlDecode on your server
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    PostString expects a string. Not an array of bytes.

    You need to use PostBytes instead.

    Your server uses an encoding other than UTF8 (which is the default). Try Windows-1255.
     
Loading...