Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ file(GLOB_RECURSE sources src/*.cpp)
string (REPLACE ";" "\n " FILES_MSG "${sources}")
message(STATUS "source files:\n ${FILES_MSG}")

add_library(unidecode ${sources})
add_library(unidecode ${sources})
15 changes: 13 additions & 2 deletions include/unidecode/unidecode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

#pragma once

#include <string>
#include "common.hpp"
#include "sections.hpp"
#include "unidecode/utf8_string_iterator.hpp"

namespace unidecode {

Expand All @@ -24,10 +26,11 @@ namespace unidecode {

uint32_t section = codepoint >> 8;
uint32_t position = codepoint & 0xff; // only ast two hex digits
// TODO: assert section < then xyz
if (section >= 256 || position >= 256)
continue;

auto table = kUnidecodeData[section];
if (table != nullptr) { // TODO: check if position < table size
if (table != nullptr) {
const char* symbol = table[position];
while (*symbol != 0) {
*out_it = *symbol;
Expand All @@ -40,4 +43,12 @@ namespace unidecode {

}

std::string UnidecodeString(const std::string &str) {
unidecode::Utf8StringIterator _begin = str.c_str();
unidecode::Utf8StringIterator _end = str.c_str() + str.length();
std::string output;
unidecode::Unidecode(_begin, _end, std::back_inserter(output));
return output;
}

}