Skip to content

Incorrect degrees symbol in example/demo.cpp #343

Description

@jwakely

return os << ' ' << gp.degrees << (unsigned char)186 << gp.minutes << '\'' << gp.seconds << '"';

This prints (unsigned char)186 to the output file, which in ISO-8859-1 is the same character as Unicode character U+00BA "Masculine Ordinal Indicator", as in 1º meaning primero in Spanish.

I think the character you intended to use is U+00B0 "Degree sign", which for ISO-8859-1 is encoded as a single character with the decimal value 176, not 186.

Maybe it would make sense to use "\u00B0" for that character, which is valid since C++11. However, the encoding used for that character would depend on compiler flags (GCC and Clang default to UTF8 for the ordinary literal encoding, MSVC ... probably doesn't), so the character written to demo_output.txt would also depend on those flags and so would not be portable.

Using (unsigned char)176) would be portable, and would at least be the correct symbol when the output is treated as ISO-8859-1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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