neonDion
neonDion

Reputation: 2358

Android Build class string encoding

I am writing an app where I want to get the model type of the device and relay it to my server. I am currently doing this in this way:

try{
    String path = URLEncoder.encode(Build.MODEL, "utf-8");
} catch (UnsupportedEncodeingException e) {
    e.printStackTrace();
}

HttpGet httpGet = new HttpGet(baseUrl + "/" + path);

My question is if the Build.MODEL string that is returned will always be UTF-8 encoded?

Does anyone know?

Thanks

Upvotes: 0

Views: 164

Answers (1)

ashoke
ashoke

Reputation: 6461

Java strings (UTF-16) can be encoded as UTF-8, see this method in String class, it clearly mentions all strings can be encoded as UTF-8.

So in your code above, path String is guaranteed to always come out as UTF-8 encoded.

Upvotes: 1

Related Questions