Tessil / hat-trie

C++ implementation of a fast and memory efficient HAT-trie
MIT License
793 stars 114 forks source link

Can i use Chinese as key? #20

Closed 1099983784 closed 5 years ago

1099983784 commented 5 years ago

excuse me,i am a beginner. Can i use Chinese as key?

Tessil commented 5 years ago

It should works without any problem it you use UTF-8.

#include <iostream>
#include <tsl/htrie_map.h>

int main() {
    tsl::htrie_map<char, int> map = {{u8"你好", 1}};

    auto it = map.find(u8"你好");
    if(it != map.end()) {
        std::cout << it.key() << ": " << it.value() << std::endl;
    }
    else {
        std::cout << "Key not found." << std::endl;
    }
}