diff options
author | Paweł Chmielowski <pchmielowski@process-one.net> | 2020-11-09 12:20:23 +0100 |
---|---|---|
committer | Paweł Chmielowski <pchmielowski@process-one.net> | 2020-11-09 12:20:35 +0100 |
commit | 81e872c11066fec3cbc92506d437a9452cffb793 (patch) | |
tree | 7f7c3ebc395b531fb011f8f07baae1a1d473e72d /src/str.erl | |
parent | Document sql_odbc_driver option (copied from docs site) (diff) |
Don't do double utf-8 conversion on translated strings in str:format
This caused garbled text in some places in webadmin when using language
that used characters > 128.
Thanks to chengshq for noticing this and providing preliminary patch.
Diffstat (limited to '')
-rw-r--r-- | src/str.erl | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/str.erl b/src/str.erl index 16e16766..c3206a26 100644 --- a/src/str.erl +++ b/src/str.erl @@ -64,10 +64,11 @@ to_float/1, prefix/2, suffix/2, - format/2, + format/2, to_integer/1, sha/1, - to_hexlist/1]). + to_hexlist/1, + translate_and_format/3]). %%%=================================================================== %%% API @@ -288,6 +289,11 @@ suffix(B1, B2) -> format(Format, Args) -> unicode:characters_to_binary(io_lib:format(Format, Args)). +-spec translate_and_format(binary(), binary(), list()) -> binary(). + +translate_and_format(Lang, Format, Args) -> + format(unicode:characters_to_list(translate:translate(Lang, Format)), Args). + -spec sha(iodata()) -> binary(). |