Skip to content

Commit

Permalink
Remove hardcoded EncodingCount, determine this compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
herwinw committed Jan 13, 2025
1 parent 08a5ae2 commit 14e2a3a
Showing 1 changed file with 52 additions and 51 deletions.
103 changes: 52 additions & 51 deletions include/natalie/encodings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,58 @@

namespace Natalie {

const size_t EncodingCount = 47;

enum class Encoding {
NONE = 0,
ASCII_8BIT = 1,
US_ASCII = 2,
UTF_8 = 3,
UTF_32LE = 4,
UTF_32BE = 5,
UTF_16LE = 6,
UTF_16BE = 7,
SHIFT_JIS = 8,
EUC_JP = 9,
IBM037 = 10,
IBM437 = 11,
IBM720 = 12,
IBM737 = 13,
IBM775 = 14,
IBM850 = 15,
IBM852 = 16,
IBM855 = 17,
IBM857 = 18,
IBM860 = 19,
IBM861 = 20,
IBM862 = 21,
IBM863 = 22,
IBM864 = 23,
IBM865 = 24,
IBM866 = 25,
IBM869 = 26,
ISO_8859_1 = 27,
ISO_8859_2 = 28,
ISO_8859_3 = 29,
ISO_8859_4 = 30,
ISO_8859_5 = 31,
ISO_8859_6 = 32,
ISO_8859_7 = 33,
ISO_8859_8 = 34,
ISO_8859_9 = 35,
ISO_8859_10 = 36,
ISO_8859_11 = 37,
ISO_8859_13 = 38,
ISO_8859_14 = 39,
ISO_8859_15 = 40,
ISO_8859_16 = 41,
Windows_1250 = 42,
Windows_1251 = 43,
Windows_1252 = 44,
Windows_1253 = 45,
Windows_1254 = 46,
Windows_1258 = 47,
enum class Encoding : size_t {
NONE,
ASCII_8BIT,
US_ASCII,
UTF_8,
UTF_32LE,
UTF_32BE,
UTF_16LE,
UTF_16BE,
SHIFT_JIS,
EUC_JP,
IBM037,
IBM437,
IBM720,
IBM737,
IBM775,
IBM850,
IBM852,
IBM855,
IBM857,
IBM860,
IBM861,
IBM862,
IBM863,
IBM864,
IBM865,
IBM866,
IBM869,
ISO_8859_1,
ISO_8859_2,
ISO_8859_3,
ISO_8859_4,
ISO_8859_5,
ISO_8859_6,
ISO_8859_7,
ISO_8859_8,
ISO_8859_9,
ISO_8859_10,
ISO_8859_11,
ISO_8859_13,
ISO_8859_14,
ISO_8859_15,
ISO_8859_16,
Windows_1250,
Windows_1251,
Windows_1252,
Windows_1253,
Windows_1254,
Windows_1258,
TERMINATOR, // Keep this as the last entry
};

constexpr size_t EncodingCount = static_cast<size_t>(Encoding::TERMINATOR) - 1;

}

0 comments on commit 14e2a3a

Please sign in to comment.