* Try and try to decipher the current locale from environmental * variables. MacOSX is hardcoded, other OS's are dynamic. If no suitable * locale can be found, don't do any conversion "" */
| 98 | * locale can be found, don't do any conversion "" |
| 99 | */ |
| 100 | static std::string GetLocalCode() |
| 101 | { |
| 102 | #if defined(__APPLE__) |
| 103 | return "UTF-8-MAC"; |
| 104 | #else |
| 105 | /* Strip locale (eg en_US.UTF-8) to only have UTF-8 */ |
| 106 | auto locale = GetCurrentLocale("LC_CTYPE"); |
| 107 | if (!locale.has_value()) return ""; |
| 108 | auto pos = locale->find('.'); |
| 109 | if (pos == std::string_view::npos) return ""; |
| 110 | locale.erase(0, pos + 1); |
| 111 | return locale; |
| 112 | #endif |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Convert between locales, which from and which to is set in the calling |
no test coverage detected