isocpp / isocpp/CppCoreGuidelines

New guidelines regarding characters and strings

Open
#727 13 comments 0 reactions 2 assignees View on GitHub

@gdr-at-ms is already working on this.

Since Sep 12, 2016.

Dominant language
CSS
Stars
45.3k
Forks
5.6k
PR merge metrics
No merged PRs in 30d

Description

I will say out multiple possible guidelines, might have gotten some wrong, because not reading with care. But all you can improve them or discard. Under portability I also mean some sort of direct communication between two programs on two different platform.

  1. Use Unicode ( u8"", u"" and U"") instead of implementation defined( "" and L"") characters and strings
    Reason: Portability.
  2. Don´t compare characters of different type with each other.
    Reason: They are likely to have different values.
  3. Don´t compare u8"" and "" strings between each other.
    Reason: They might not be same.
  4. Don´t compare signed, unsigned and plain characters and strings with each other.
    Reason: They might not be same.
  5. Prefer to use same type of character and string for one project
    Reason: Its easy to accidentally mix them up.
  6. Prefer to have characters unsigned?
    Reason: Portability. Plain char is implementation defined.
  7. Don't use byte/single character based string manipulations on variable length encodings like UTF-8, UTF-16.
    Exception: UTF-32 as it is fixed-length?
    Reason: Letter might be combination of multiple characters.
  8. Care with endianness for UTF-16 and UTF-32?
    Reason: Portability

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.