2009-01-12から1日間の記事一覧

UTF-8 + 文字数カウント

C++ で UTF-8 の文字数を数えるコードを試しに書いてみたメモ。 バイト数ではなく、文字数。 #include #include int strlen_utf8( const char *buff ) { if( buff == NULL ) return 0; int count = 0; int pos = 0; int max_bytes = strlen( buff ); // BOM …