Giter Site home page Giter Site logo

unidecode's People

Contributors

marekru avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

unidecode's Issues

Unidecode for `std::string`

Create version of the Unidecode function which takes std::string as an argument.

Usage:

std::string decoded = Unidecode( u8"mačka" )

Example implementation:

auto Unidecode(... utf8_string)
{
    std::string result;
    unidecode::Utf8StringIterator begin{utf8_string.c_str()};
    unidecode::Utf8StringIterator end{utf8_string.c_str() + utf8_string.length()};
    unidecode::Unidecode(begin, end, std::back_inserter(result));
    return result;        
}

Wrong values in the table

section: 1, position: 51, '' != 'ij' 
section: 1, position: 242, 'D' != 'Dz' 
section: 2, position: 32, '[?]' != 'N' 
section: 2, position: 33, '[?]' != 'd' 
section: 2, position: 52, '[?]' != 'l' 
section: 2, position: 53, '[?]' != 'n' 
section: 2, position: 54, '[?]' != 't' 
section: 2, position: 55, '[?]' != 'j' 
section: 2, position: 56, '[?]' != 'db' 
section: 2, position: 57, '[?]' != 'qp' 
section: 2, position: 58, '[?]' != 'A' 
section: 2, position: 59, '[?]' != 'C' 
section: 2, position: 60, '[?]' != 'c' 
section: 2, position: 61, '[?]' != 'L' 
section: 2, position: 62, '[?]' != 'T' 
section: 2, position: 63, '[?]' != 's' 
section: 2, position: 64, '[?]' != 'z' 
section: 2, position: 67, '[?]' != 'B' 
section: 2, position: 68, '[?]' != 'U' 
section: 2, position: 69, '[?]' != '^' 
section: 2, position: 70, '[?]' != 'E' 
section: 2, position: 71, '[?]' != 'e' 
section: 2, position: 72, '[?]' != 'J' 
section: 2, position: 73, '[?]' != 'j' 
section: 2, position: 74, '[?]' != 'q' 
section: 2, position: 75, '[?]' != 'q' 
section: 2, position: 76, '[?]' != 'R' 
section: 2, position: 77, '[?]' != 'r' 
section: 2, position: 78, '[?]' != 'Y' 
section: 2, position: 79, '[?]' != 'y' 
section: 2, position: 121, 'R' != 'r' 
section: 2, position: 122, 'R' != 'r' 
section: 2, position: 123, 'R' != 'r' 
section: 2, position: 124, 'R' != 'r' 
section: 2, position: 127, 'R' != 'r' 
section: 2, position: 137, 'U' != 'u' 
section: 2, position: 141, 'W' != 'w' 
section: 2, position: 142, 'Y' != 'y' 
section: 2, position: 174, '[?]' != 'h' 
section: 2, position: 175, '[?]' != 'h' 
section: 2, position: 176, 'k' != 'h' 

Benchmark GetCodePoint method

inline unicode_char GetCodePoint(const char* ptr) {

Look at this code and try to benchmark this using google benchmark!
There might be an improvement using fixed size of masks 4.

example code:

    static const uint8_t kMask0[] = {0xff, 0x00, 0x00, 0x00};
    static const uint8_t kMask1[] = {0x3f, 0x1f, 0x00, 0x00};
    static const uint8_t kMask2[] = {0x3f, 0x3f, 0x0f, 0x00};
    static const uint8_t kMask3[] = {0x3f, 0x3f, 0x3f, 0x07};

//...

   inline unicode_char GetCodePoint(const char* ptr) {
        uint32_t code_point_size = GetCodePointSize(*ptr);
        const uint8_t* mask = kCodePointMasks[code_point_size - 1];
        unicode_char result = 0;
        for (uint32_t i = 4; i-->0; ptr++) {
            result |= (*ptr & mask[i]) << 6 * i;
        }
        return result;
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.