Codepagex.Backend:use Codepagex.Backend, encodings: [...]in a module of your own compiles those encodings into it, with the functions ofCodepagexfor them. A library can so have the encodings it needs without the application configuring Codepagex, and without recompiling it.- Aliases for the Windows code pages:
:windows_874,:windows_932,:windows_936,:windows_949,:windows_950and:windows_1250to:windows_1258, for"VENDORS/MICSFT/WINDOWS/CP874"and so on. Like the other aliases,Codepagexhas them only for the encodings it is configured with.
:asciiis now plain US-ASCII, where every byte 0..127 maps to the same codepoint. It used to be an alias for"VENDORS/MISC/US-ASCII-QUOTES", which maps'and`to the curly quotes U+2019 and U+2018. To keep the old behavior, add"VENDORS/MISC/US-ASCII-QUOTES"to:encodingsand use that name.to_string/4andfrom_string/4now return{:error, reason, acc}when the outermissing_funreturns{:error, reason}. Previously the 2-tuple was returned as it was, contradicting the typespec. Code that matched{:error, reason}on that result must be updated.Codepagex.Errornow always has a string message. A reason that is not a string is converted withinspect/1. Before,Exception.message/1raised for such exceptions.- Encoding CP932 now uses the standard byte sequences for the 23 codepoints
that have several, for example U+2252 is
81E0and not the NEC duplicate8790. Decoding is unchanged. - The alias
:iso_8859_12is removed. It never worked, as there is no ISO 8859-12 mapping. - An entry in
config :codepagex, :encodingsthat matches no encoding now gives a compile time warning. Such entries used to be ignored silently. Projects compiled with--warnings-as-errorswill fail on a mistyped entry.
replace_nonexistent/1no longer crashes withFunctionClauseErroron input that is not valid UTF-8. Each invalid byte is replaced.to_string!/4andfrom_string!/4raiseCodepagex.Errorwhen the outermissing_funfails, instead ofCaseClauseError.- An
ArgumentErrorraised inside amissing_funis no longer reported asUnknown encodingwhen the encoding is given as a string. - Which encodings are compiled no longer depends on where the project is
located on disk. A path containing for example
next,readmeorunicodecould result in no encodings, or wrong encoding names. - The test configuration and the README example used the encoding names
MISC/CP424andMISC/CP856, which do not exist. The names areVENDORS/MISC/CP424andVENDORS/MISC/CP856. - Typespecs corrected: the accumulator is any term and not an integer, the
inner
missing_funreturns{:error, reason, acc}, and the argument and return types offrom_string/4. - Benchmarks: the 1M ISO8859-1 input was about 42 times too large, and some
results were labeled
from_stringwhento_stringwas measured. The Benchee task no longer keeps all results in memory.
- Continuous integration moved from Travis CI to GitHub Actions, testing Elixir 1.16 to 1.20 with Erlang/OTP 24 to 29, and running format checking, Credo and Dialyzer.
- README documents how regexes in
:encodingsbehave on Erlang/OTP 28.