Windows での文字コードの変換部分は MultiByteToWideChar,WideCharToMultiByte でうまく機能している.
exe \ 入力 | シフトJIS | UTF-16 | UTF-8 |
_UNICODE | → WideChar | そのまま | → WideChar(CP_UTF8) |
_MBCS | そのまま | → MultiByte | → WideChar(CP_UTF8) → MultiByte |
MultiByteToWideChar,WideCharToMultiByte の使い方は C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\crt\src\ などの mbstowcs.c,wcstombs.c を参照.
MSDN で見つけた記事
C++ – STL の文字列クラスと Win32 API による Unicode エンコーディングの変換
Linux 環境での動作は 2014/03 に一度調べていたみたいで ” gcc iconv ” とコメントになっている.
それで https://ja.wikipedia.org/wiki/Iconv にあるコードを Raspberry Pi 環境で実行するとうまく変換できる.
コンパイルエラーになったので string.h のインクルードが必要かも?
同じコードを Synology NAS の DS116 でコンパイルして実行するとうまく動作しない
(そのままのコードでは止まってしまう).
iconv_open で (iconv_t)-1 が返されていて errno は EINVAL になってしまう.
iconv コマンドを試すと Raspberry Pi では OK .
Synology NAS は iconv が存在しない.
検索すると uconv が使えると書かれている.
https://forum.synology.com/enu/viewtopic.php?t=82591
Iwao@DS116:~$ uconv -L
ASCII-Latin Accents-Any Amharic-Latin/BGN Any-Accents Any-Publishing Arabic-Latin Arabic-Latin/BGN Armenian-Latin Armenian-Latin/BGN Azerbaijani-Latin/BGN Belarusian-Latin/BGN Bengali-Devanagari Bengali-Gujarati Bengali-Gurmukhi Bengali-Kannada Bengali-Latin Bengali-Malayalam Bengali-Oriya Bengali-Tamil Bengali-Telugu Bopomofo-Latin Bulgarian-Latin/BGN Cyrillic-Latin Devanagari-Bengali Devanagari-Gujarati Devanagari-Gurmukhi Devanagari-Kannada Devanagari-Latin Devanagari-Malayalam Devanagari-Oriya Devanagari-Tamil Devanagari-Telugu Digit-Tone Fullwidth-Halfwidth Georgian-Latin Georgian-Latin/BGN Greek-Latin Greek-Latin/BGN Greek-Latin/UNGEGN Gujarati-Bengali Gujarati-Devanagari Gujarati-Gurmukhi Gujarati-Kannada Gujarati-Latin Gujarati-Malayalam Gujarati-Oriya Gujarati-Tamil Gujarati-Telugu Gurmukhi-Bengali Gurmukhi-Devanagari Gurmukhi-Gujarati Gurmukhi-Kannada Gurmukhi-Latin Gurmukhi-Malayalam Gurmukhi-Oriya Gurmukhi-Tamil Gurmukhi-Telugu Halfwidth-Fullwidth Han-Latin Han-Latin/Names Hangul-Latin Hans-Hant Hant-Hans Hebrew-Latin Hebrew-Latin/BGN Hiragana-Katakana Hiragana-Latin IPA-XSampa Jamo-Latin Kannada-Bengali Kannada-Devanagari Kannada-Gujarati Kannada-Gurmukhi Kannada-Latin Kannada-Malayalam Kannada-Oriya Kannada-Tamil Kannada-Telugu Katakana-Hiragana Katakana-Latin Katakana-Latin/BGN Kazakh-Latin/BGN Kirghiz-Latin/BGN Korean-Latin/BGN Latin-ASCII Latin-Arabic Latin-Armenian Latin-Bengali Latin-Bopomofo Latin-Cyrillic Latin-Devanagari Latin-Georgian Latin-Greek Latin-Greek/UNGEGN Latin-Gujarati Latin-Gurmukhi Latin-Hangul Latin-Hebrew Latin-Hiragana Latin-Jamo Latin-Kannada Latin-Katakana Latin-Malayalam Latin-NumericPinyin Latin-Oriya Latin-Syriac Latin-Tamil Latin-Telugu Latin-Thaana Latin-Thai Macedonian-Latin/BGN Malayalam-Bengali Malayalam-Devanagari Malayalam-Gujarati Malayalam-Gurmukhi Malayalam-Kannada Malayalam-Latin Malayalam-Oriya Malayalam-Tamil Malayalam-Telugu Maldivian-Latin/BGN Mongolian-Latin/BGN NumericPinyin-Latin NumericPinyin-Pinyin Oriya-Bengali Oriya-Devanagari Oriya-Gujarati Oriya-Gurmukhi Oriya-Kannada Oriya-Latin Oriya-Malayalam Oriya-Tamil Oriya-Telugu Pashto-Latin/BGN Persian-Latin/BGN Pinyin-NumericPinyin Publishing-Any Russian-Latin/BGN Serbian-Latin/BGN Simplified-Traditional Syriac-Latin Tamil-Bengali Tamil-Devanagari Tamil-Gujarati Tamil-Gurmukhi Tamil-Kannada Tamil-Latin Tamil-Malayalam Tamil-Oriya Tamil-Telugu Telugu-Bengali Telugu-Devanagari Telugu-Gujarati Telugu-Gurmukhi Telugu-Kannada Telugu-Latin Telugu-Malayalam Telugu-Oriya Telugu-Tamil Thaana-Latin Thai-Latin Tone-Digit Traditional-Simplified Turkmen-Latin/BGN Ukrainian-Latin/BGN Uzbek-Latin/BGN XSampa-IPA am-am_FONIPA az-Lower az-Title az-Upper ch-ch_FONIPA cs-cs_FONIPA cs-ja cs-ko cs_FONIPA-ja cs_FONIPA-ko dsb-dsb_FONIPA el-Lower el-Title el-Upper eo-eo_FONIPA es-am es-es_FONIPA es-ja es-zh es_419-ja es_419-zh es_FONIPA-am es_FONIPA-es_419_FONIPA es_FONIPA-ja es_FONIPA-zh ia-ia_FONIPA it-am it-ja ja_Latn-ko ja_Latn-ru ky-ky_FONIPA la-la_FONIPA lt-Lower lt-Title lt-Upper nl-Title pl-ja pl-pl_FONIPA pl_FONIPA-ja ro-ja ro-ro_FONIPA ro_FONIPA-ja ru-ja ru-zh sk-ja sk-sk_FONIPA sk_FONIPA-ja tlh-tlh_FONIPA tr-Lower tr-Title tr-Upper uz_Cyrl-uz_Latn uz_Latn-uz_Cyrl yo-yo_BJ zh_Latn_PINYIN-ru Any-Null Any-Lower Any-Upper Any-Title Any-Name Name-Any Any-Remove Any-Hex/Unicode Any-Hex/Java Any-Hex/C Any-Hex/XML Any-Hex/XML10 Any-Hex/Perl Any-Hex Hex-Any/Unicode Hex-Any/Java Hex-Any/C Hex-Any/XML Hex-Any/XML10 Hex-Any/Perl Hex-Any Any-NFC Any-NFKC Any-NFD Any-NFKD Any-FCD Any-FCC Any-ch_FONIPA Any-Latin Any-Telugu Any-Gurmukhi Any-Gujarati Any-Malayalam Any-Oriya Any-Devanagari Any-Kannada Any-Tamil Any-cs_FONIPA Any-ru Any-Bengali Any-uz_Latn Any-Katakana Any-ro_FONIPA Any-ky_FONIPA Any-zh Any-yo_BJ Any-am Any-es_419_FONIPA Any-eo_FONIPA Any-es_FONIPA Any-sk_FONIPA Any-Hant Any-Hans Any-Hiragana Any-la_FONIPA Any-Syriac Any-Greek Any-Greek/UNGEGN Any-Cyrillic Any-Hangul Any-Bopomofo Any-Arabic Any-Thai Any-Armenian Any-Thaana Any-Georgian Any-Hebrew Any-am_FONIPA Any-dsb_FONIPA Any-ia_FONIPA Any-uz_Cyrl Any-pl_FONIPA
Iwao@DS116:~$
iconv_open で失敗した場合,iconv コマンドまたは uconv コマンドとするか?
2022/07/15
SynoCli File Tools v2.6-16 で iconv が追加された.
SynoCli File Tools などのインストール方法は次の所に書いています.
https://dev.mish.work/wordpress/2022/06/15/ds116-entware/