Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endian enum naming change in zig-0.12.0-dev.1388 #28

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/encoding.zig
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ pub const DefaultDecoder = struct {
state: union(enum) {
start,
utf8: Utf8Decoder,
utf16_le: Utf16Decoder(.Little),
utf16_be: Utf16Decoder(.Big),
utf16_le: Utf16Decoder(.little),
utf16_be: Utf16Decoder(.big),
} = .start,

pub const Error = Utf8Decoder.Error || Utf16Decoder(.Little).Error || Utf16Decoder(.Big).Error;
pub const Error = Utf8Decoder.Error || Utf16Decoder(.little).Error || Utf16Decoder(.big).Error;

pub const max_encoded_codepoint_len = 4;
const bom = 0xFEFF;
Expand Down Expand Up @@ -373,8 +373,8 @@ pub fn Utf16Decoder(comptime endian: std.builtin.Endian) type {

pub fn adaptTo(_: *Self, encoding: []const u8) error{InvalidEncoding}!void {
if (!(ascii.eqlIgnoreCase(encoding, "utf-16") or
(endian == .Big and ascii.eqlIgnoreCase(encoding, "utf-16be")) or
(endian == .Little and ascii.eqlIgnoreCase(encoding, "utf-16le"))))
(endian == .big and ascii.eqlIgnoreCase(encoding, "utf-16be")) or
(endian == .little and ascii.eqlIgnoreCase(encoding, "utf-16le"))))
{
return error.InvalidEncoding;
}
Expand All @@ -394,7 +394,7 @@ test Utf16Decoder {
"\x00\xD8\x00\x00" ++ // unpaired high surrogate followed by U+0000
"\xFF\xDF" // unpaired low surrogate
;
_ = try testDecode(Utf16Decoder(.Little), input, &.{
_ = try testDecode(Utf16Decoder(.little), input, &.{
'\x00',
'A',
'b',
Expand All @@ -417,7 +417,7 @@ test Utf16Decoder {
"\xD8\x00\x00\x00" ++ // unpaired high surrogate followed by U+0000
"\xDF\xFF" // unpaired low surrogate
;
_ = try testDecode(Utf16Decoder(.Big), input, &.{
_ = try testDecode(Utf16Decoder(.big), input, &.{
'\x00',
'A',
'b',
Expand Down