pusherman / react-native-network-info

React Native library for getting information about the devices network
MIT License
356 stars 106 forks source link

IP uses locale-specific characters for digits in string (Android) #119

Open MasterKenth opened 2 years ago

MasterKenth commented 2 years ago

Using getIPV4Address on Android with the device set to use a language that uses different characters than 0-9 to represent digits causes the returned string to also use those characters. Most notably are some Arabic languages that uses Arabian numerals.

For example, 10.0.2.16 is returned as ١٠.٠.٢.١٦.

This only seems to affect Android. The toString used likely is locale-aware.

While it can be good to use locale-specific representation if the IP is displayed to the user, this seems generally bad as it's inconsistent with iOS and causes issues with other systems, for example when we pass the IP along to our backend.

This probably affect other functions than getIPV4Address as well however that is the function where I stumbled upon the issue.

EDIT: did some digging and it seems to come from the use of String.format which doesn't specify the locale.