My Android app uses an enum type to define certain API endpoints.
public static enum API_ENDPOINT{
MISSION, FEATURED_MEDIA
}
The enum type seems an appropriate argument for methods that are dependent on the API call type, but I'm unable to translate enums to consistent Strings (i.e for mapping to API endpoint urls) across devices configured with different languages.
In Turkish API_ENDPOINT.values()
returns: mıssıon, featured_medıa
In English API_ENDPOINT.values()
returns: mission, featured_media
An obvious solution is an additional data structure that maps API_ENDPOINT
to hard-coded string endpoints, but I'm curious as to whether this behavior of enum.values()
is intended and/or avoidable.
Solved: Thanks everyone for the insight. It turns out deeper in the logic to convert API_ENDPOINT
to a URL string I used String.toLowerCase()
without specifying a Locale, which resulted in the undesirable behavior. This has been replaced with String.toLowerCase(Locale.US)