srctree

Robin Linden parent ac2f76d8 16c90fb9
unicode: Give things better names

inlinesplit
unicode/unicode.cpp added: 13, removed: 13, total 0
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "unicode/unicode.h"
#include "unicode/normalization.h"
 
#include "unicode/unicode_data.h"
 
@@ -42,7 +42,7 @@ void decompose_to(std::ostream &os, char32_t code_point) {
 
} // namespace
 
std::string Unicode::decompose(std::string_view input) {
std::string Normalization::decompose(std::string_view input) {
std::stringstream ss{};
 
for (auto const code_point : util::CodePointView{input}) {
 
unicode/unicode.h added: 13, removed: 13, total 0
@@ -2,15 +2,15 @@
//
// SPDX-License-Identifier: BSD-2-Clause
 
#ifndef UNICODE_UNICODE_H_
#define UNICODE_UNICODE_H_
#ifndef UNICODE_NORMALIZATION_H_
#define UNICODE_NORMALIZATION_H_
 
#include <string>
#include <string_view>
 
namespace unicode {
 
class Unicode {
class Normalization {
public:
// Normalizes the input into its canonical decomposition, NFD.
static std::string decompose(std::string_view);
 
unicode/unicode_test.cpp added: 13, removed: 13, total 0
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "unicode/unicode.h"
#include "unicode/normalization.h"
 
#include "etest/etest2.h"
 
@@ -10,20 +10,20 @@ int main() {
etest::Suite s{};
 
s.add_test("not decomposed", [](etest::IActions &a) {
a.expect_eq(unicode::Unicode::decompose("abc123xyz"), "abc123xyz"); //
a.expect_eq(unicode::Normalization::decompose("abc123xyz"), "abc123xyz"); //
});
 
s.add_test("decomposed", [](etest::IActions &a) {
// A + COMBINING RING ABOVE
a.expect_eq(unicode::Unicode::decompose("Å"), "A\xcc\x8a");
a.expect_eq(unicode::Normalization::decompose("Å"), "A\xcc\x8a");
 
// s + COMBINING DOT BELOW + COMBINING DOT ABOVE
a.expect_eq(unicode::Unicode::decompose("ṩ"), "s\xcc\xa3\xcc\x87");
a.expect_eq(unicode::Normalization::decompose("ṩ"), "s\xcc\xa3\xcc\x87");
});
 
s.add_test("mixed", [](etest::IActions &a) {
// s + COMBINING DOT BELOW + COMBINING DOT ABOVE
a.expect_eq(unicode::Unicode::decompose("123ṩ567"),
a.expect_eq(unicode::Normalization::decompose("123ṩ567"),
"123"
"s\xcc\xa3\xcc\x87"
"567");