Skip to content

incorrect character set mapping for some escape sequences #421

Description

@GorillaSapiens

refer to https://llvm-mos.org/wiki/Character_set

and also code in mos-platform/c64/charset.h and similar.

C17 §5.1.1.2 and §6.4.5 require that ordinary characters are mapped via the source character set, while escape sequences are converted directly to execution character set members, whose values are implementation-defined; therefore "A\x41" may produce two different characters.

this applies to all hex and octal escape sequences. when a programmer puts \x41, they really want that exact byte, not an 'A'.

the method on the Character_set wiki page simply will not work, because by the time those operator"" get called, the "\x41" has already been translated to "A".

the correct way to handle this is to use raw strings, and translate the escape sequences ourselves in our operator""_foo functions.

the correct wiki examples would then be RU"HELLO"_foo

and additional code would be needed in

./mos-platform/atari8-common/charset.h
./mos-platform/cx16/charset.h
./mos-platform/pet/charset.h
./mos-platform/vic20/charset.h
./mos-platform/c64/charset.h

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions