sameerkapps / SecureStorage

119 stars 32 forks source link

Umlaut Problem in Android #11

Closed mahmet closed 7 years ago

mahmet commented 7 years ago

Hello, I have problems with German Umlaut's when restoring strings with the SecureStorage Plugin. The strings are saved as e.g. "Zürich" and then when I retrieve the string back with .GetValue I get "Z?rich" back. This problem only occurs on Android.

sameerkapps commented 7 years ago

I have not tested it in German. You may want to ask on stack overflow and/or Xamarin forums to see, if anyone has similar experience or this is one off. Or is it specific to that localized make and model of Android. We an go from there. Thanks.

mahmet commented 7 years ago

I guess the problem is in the SecureStorage Android implementation in the GetValue() method: var encodedBytes = entry.SecretKey.GetEncoded(); return Encoding.ASCII.GetString(encodedBytes);

I found something on the Internet about this issue (https://bytes.com/topic/c-sharp/answers/279346-encoding-umlaut-becomes-when-using-system-text-encoding-ascii). Can we maybe try a different encoding like UTF-8 ?

mahmet commented 7 years ago

I have made a Pull Request for this problem

sameerkapps commented 7 years ago

Appreciate your efforts. It looks like UTF8 is backwards compatible with ASCII. So it should not affect the existing users. I will test and merge the pull request in a few days. Thx.

sameerkapps commented 7 years ago

Checked in the code. It required more changes than your branch. So took that and merged. Thanks again for your efforts.