behong / gcm

Automatically exported from code.google.com/p/gcm
Apache License 2.0
0 stars 0 forks source link

Wrong message encoding if sent from platform with encoding other than UTF-8 #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When I send string message with national characters (in my case Polish) from 
platform with encoding set to e.g. cp1250 I get corrupted message on the device.

I think it's because in method post(String, String, String) in line 552 
<code>
byte[] bytes = body.getBytes();
</code>
getBytes uses default platform encoding which is in my case cp1250 and default 
encoding for content application/json is UTF-8.

By the way method sendNoRetry(Message, String) uses URLEncoder.encode(value, 
UTF8) to encode values and sendNoRetry(Message message, List<String>) does not.

Original issue reported on code.google.com by tlas...@gmail.com on 29 Nov 2012 at 2:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
You can find the fix for this bug in issue #16

Original comment by KurtHu...@gmail.com on 25 Aug 2014 at 9:14

GoogleCodeExporter commented 9 years ago
And issue #17 has even a test case

Original comment by KurtHu...@gmail.com on 25 Aug 2014 at 9:15

GoogleCodeExporter commented 9 years ago
You can find a repo with the fix of issue #17 here:

https://github.com/kurthuwig/gcm/commit/d37f4d1c37ed8deaf1a161ca7b881c1d843f80df

Original comment by KurtHu...@gmail.com on 25 Aug 2014 at 9:39