ホーム » 検索結果: iconv

検索結果: iconv

2024年4月
 123456
78910111213
14151617181920
21222324252627
282930  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,456 アクセス



PHP から iconv コマンド呼び出し

シフトJIS のデータファイルをアップロードして WebGL で表示のテスト.
PHP から作成した .out を呼び出しているが,その中で文字コードの変換がうまく機能していない.
.out の中では iconv ライブラリを呼び出す.うまく機能しない時は iconv または uconv コマンド.
.out をコンソールから実行した時はうまく機能している.


いろいろと動作を調べていると,次の様なコマンドが PHP から呼出された時うまく機能していない様子.
iconv -f CP932 shiftjis.txt > out_file.txt
コンソールでは OK .
ここまで絞り込むのに 1 日かかった


今回の修正前 Synology NAS では次の様にしていた.
uconv -f sjis -t utf8 shiftjis.txt -o out_file.txt


先日テストしていた時 ASUSTOR NAS ではエラーになったので,単純に -t オプションを取ってしまった.

Iwao@AS5202T:/volume1/Web/Test/mics/tc_xconv $ iconv -f CP932 -t utf8 shiftjis.txt
iconv: conversion to utf8 unsupported
iconv: try 'iconv -l' to get the list of supported encodings
Iwao@AS5202T:/volume1/Web/Test/mics/tc_xconv $

iconv -l を幾つかの環境で調べていると “utf8” の指定がうまくない.
いろいろな環境でうまく機能しそうなのは “UTF-8” .
Fedora iconv -l | grep -i utf
Raspberry Pi iconv -l | grep -i utf
DS116 uconv -l | grep -i utf
AS5202T iconv -l | grep -i utf


-t オプションを指定しないとうまくないみたいで,次の様に変更.
iconv -f CP932 -t UTF-8 shiftjis.txt > out_file.txt
これで意図した動作になった.


2020/09/08 変換できない文字が存在した時に止まらない様な指定を追加.
https://mish.myds.me/wordpress/dev/2020/09/07/upload-mbcs-name/
exec_ic.hxx
text_gnc.hxx

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

ASUSTOR NAS 上の iconv , whois

ASUSTOR NAS の iconv は Fedora や Synology NAS uconv の -o(出力ファイルの指定)がない.

[Iwao@fedora ~]$ iconv --help
使用法: iconv [OPTION...] [FILE...]
与えられたファイルのエンコーディングをあるエンコーディングから別のエンコーディングに変換します。
 入力/出力形式の指定:
  -f, --from-code=NAME       元のテキストのエンコーディング
  -t, --to-code=NAME         出力用のエンコーディング
 情報:
  -l, --list
                             全ての既知の符号化された文字集合を一覧表示します
 出力制御:
  -c                         出力から無効な文字を取り除く
  -o, --output=FILE          出力ファイル
  -s, --silent               警告を抑制する
      --verbose              経過情報を表示する

  -?, --help                 このヘルプ一覧を表示する
      --usage                短い使用方法を表示する
  -V, --version              プログラムのバージョンを表示する
長い形式のオプションで必須または任意の引数は、それに対応する短い形式のオプションでも同様に必須または任意です。
For bug reporting instructions, please see:
.
[Iwao@fedora ~]$ iconv --version
iconv (GNU libc) 2.30
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
作者 Ulrich Drepper。
[Iwao@fedora ~]$ 
Iwao@AS5202T:/volume1/home/Iwao $ iconv --help
Usage: iconv [OPTION...] [-f ENCODING] [-t ENCODING] [INPUTFILE...]
or:    iconv -l
Converts text from one encoding to another encoding.
Options controlling the input and output format:
  -f ENCODING, --from-code=ENCODING
                              the encoding of the input
  -t ENCODING, --to-code=ENCODING
                              the encoding of the output
Options controlling conversion problems:
  -c                          discard unconvertible characters
  --unicode-subst=FORMATSTRING
                              substitution for unconvertible Unicode characters
  --byte-subst=FORMATSTRING   substitution for unconvertible bytes
  --widechar-subst=FORMATSTRING
                              substitution for unconvertible wide characters
Options controlling error output:
  -s, --silent                suppress error messages about conversion problems
Informative output:
  -l, --list                  list the supported encodings
  --help                      display this help and exit
  --version                   output version information and exit
Report bugs to .
Iwao@AS5202T:/volume1/home/Iwao $ iconv --version
iconv (GNU libiconv 1.14)
Copyright (C) 2000-2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Bruno Haible.
Iwao@AS5202T:/volume1/home/Iwao $

AS5202T iconv help
次の様にリダイレクトして指定すれば良い.
iconv -f CP932 sjis_file.txt > out_file.txt
他にも whois はサーバを指定しないとうまく機能しない?
whois -h whois.apnic.net 27.92.169….

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

日本語名ファイルのアップロード

次の所から日本語名のファイルをアップロードはできていたが,コードでの対応はうまくできていなかった.
https://itl.mish.work/…/upload.htm
そのため,アップロード時に 7 ビットのファイル名に変換することで対応していた.
これらのコードを書いたのは 3 年位前なので,その当時はまだよくわかっていなかった.
https://dev.mish.work/wordpress/2017/09/04/chttpfile-http-post/
またテクスチャファイル名などが日本語の場合はうまくいかないことも多かった.


最初,日本語名でそのままアップロードすると,いろいろ困った現象に…
PC から NAS 上のアップロード先のファイルが見えなくなってしまった.
一度スマートフォンの NAS 用のファイルマネージャから参照すると PC でも見えるようにはなった.
動作を見ると,サーバ側のコードは動作しているが,格納しているファイル名がうまく渡せていない.
ログなどを確認すると,デバッグ用 MBCS.exe でファイル名が「シフト JIS」のままになっていた.


送られるデータとしては次の所にあたる部分.
$_FILES[‘userfile’][‘name’]
これを UTF-8 にして渡す必要がある.
コードとしては次の所.

v_char	Make_send_data	(LPCTSTR upFile,LPCTSTR ___boundary)
{
	v_char	up_Data = v_c_Load(upFile) ;
	v_char	sndData ;
	{
		tstring	ct_boundary	=	___boundary ;
		tstring	file_img	=	::QuotM_Add(_T("file_img")) ;
		tstring	fileName	=	::QuotM_Add(::Path_GetName(upFile)) ;
		tstring	dataPre ;
		tstring	dataPst ;
		dataPre+=	CT_boundary__	+	ct_boundary	+			C_CRLF ;
		dataPre+=	CD_cd_f_d_n_	+	file_img	+	CD_cd__fn_	;
		dataPre+=				fileName	+			C_CRLF ;
		dataPre+=	CT_ct_a_o_s							C_CRLF ;
		dataPre+=									C_CRLF ;
		dataPst+=									C_CRLF ;
		dataPst+=	CT_boundary__	+	 ct_boundary	+	CT_boundary__	C_CRLF ;
	//	v_char	vc_pref = ::To_v_char(::To__string(dataPre.c_str())) ;
		v_char	vc_pref = ::To_v_char(::To_UTF8   (dataPre.c_str())) ;
		v_char	vc_post = ::To_v_char(::To__string(dataPst.c_str())) ;
		sndData.insert(sndData.end(),vc_pref.begin(),vc_pref.end()) ;
		sndData.insert(sndData.end(),up_Data.begin(),up_Data.end()) ;
		sndData.insert(sndData.end(),vc_post.begin(),vc_post.end()) ;
		}
	return	sndData ;
	}

To__string でそのまま char の配列としていたものを UTF-8 にしてから char の配列に.
UpFile.hxx アップロードするファイル名を UTF-8 に
UpFile.hxx
quotm.hxx


2020/09/08
今度はサーバ側のコード.
本当はクライアントの CInternetSession のコンストラクタで与える User Agent .
UTF-8 でセットすれば良いのはわかるが,引数が LPCTSTR なのでどうすれば良いかわからず.
そのためサーバ側のログを出力する部分でうまく機能しないことがある.
Synology NAS では,一部文字化けするが特に問題なさそう.
ASUSTOR NAS や QNAP NAS では,20200908.txt の読み込み時に止まっている様子.
次の様に //IGNORE を付加して変換.

iconv API は iconv_open(_T("UTF-8//IGNORE")) 
iconv -f CP932 -t UTF-8//IGNORE 20200908.txt >  20200908.uf8
uconv -f CP932 -t UTF-8 -i      20200908.txt -o 20200908.uf8
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

TS-253D セットアップ – 7

幾つかの気づいたことをメモ.


SSH 接続 して python3 が動作しない.
python 2.7 は起動する.
App Center で Python3 はインストールしてある.
はっきりわからないが,App Center でインストールしたものと SSH 接続してのものとは異なるみたい.
admin で入って opkg install python3 でインストール.
QNAP NAS に Python 3 インストール
これで SSH 接続でも可能になった.


python3 がインストールできない場合,その前に entware のインストールが必要.
https://dev.mish.work/wordpress/2020/08/29/ts253d-setup-3-opkg/


インストールされている PHP は 7.3.7 .
アップロードできるファイルサイズはデフォルトで十分.


zip , unzip , 7z , convert は入っている.

[Iwao@TS253D prt_text]$ tree /mnt/ext/opt/ImageMagick/usr/local/
/mnt/ext/opt/ImageMagick/usr/local/
└── sbin
    ├── composite
    ├── convert
    └── identify

1 directory, 3 files
[Iwao@TS253D prt_text]$      

iconv コマンドは入ってなさそうだが iconv API は使える.


2020/08/18 pip の追加.

[~] # opkg install python3-pip
Installing python3-pip (19.2.3-4) to root...
Downloading http://bin.entware.net/x64-k3.2/python3-pip_19.2.3-4_x64-3.2.ipk
Installing python3-pkg-resources (41.2.0-3) to root...
Downloading http://bin.entware.net/x64-k3.2/python3-pkg-resources_41.2.0-3_x64-3.2.ipk
Installing python3-setuptools (41.2.0-3) to root...
Downloading http://bin.entware.net/x64-k3.2/python3-setuptools_41.2.0-3_x64-3.2.ipk
Installing python-pip-conf (0.1-1) to root...
Downloading http://bin.entware.net/x64-k3.2/python-pip-conf_0.1-1_x64-3.2.ipk
Configuring python-pip-conf.
Configuring python3-pkg-resources.
Configuring python3-setuptools.
Configuring python3-pip.
[~] #          

QNAP NAS に Flask のインストール


https://jml.mish.work/various/nas/qnap-nas.html
https://jml.mish.work/various/nas.html

Is this 投稿 useful? Useful Useless 1 of 1 people say this 投稿 is useful.

TS-253D セットアップ – 6

以前調べた時は,Synology NAS と同様に面倒だと思ったが…


検索すると
QNAPにEntware-stdをインストールする
QNAP NAS  QKPG Store の登録
QNAP NAS  Entware-std のインストール

Microsoft Windows [Version 10.0.18362.1016]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Iwao>\\WDCloud\Public\Document\bat\ssh_ts253d.bat

C:\Users\Iwao>cd C:\Users\Iwao\AppData\Local\Temp

C:\Users\Iwao\AppData\Local\Temp>ssh -l Iwao -p 22 ts253d
Iwao@ts253d's password:
[Iwao@TS253D ~]$ gcc
-sh: gcc: command not found
[Iwao@TS253D ~]$ opkg
-sh: opkg: command not found
[Iwao@TS253D ~]$ /opt/bin/opkg
opkg must have one sub-command argument
usage: opkg [options...] sub-command [arguments...]
where sub-command is one of:

Package Manipulation:
        update                  Update list of available packages
        upgrade <pkgs>          Upgrade packages
        install <pkgs>          Install package(s)
        configure <pkgs>        Configure unpacked package(s)
        remove <pkgs|regexp>    Remove package(s)
        flag <flag> <pkgs>      Flag package(s)
         <flag>=hold|noprune|user|ok|installed|unpacked (one per invocation)

...

 regexp could be something like 'pkgname*' '*file*' or similar
 e.g. opkg info 'libstd*' or opkg search '*libop*' or opkg remove 'libncur*'
[Iwao@TS253D ~]$ 
[Iwao@TS253D ~]$ /opt/bin/opkg install gcc
Installing gcc (7.4.0-5) to root...
Downloading http://bin.entware.net/x64-k3.2/gcc_7.4.0-5_x64-3.2.ipk
Installing zlib (1.2.11-3) to root...
Downloading http://bin.entware.net/x64-k3.2/zlib_1.2.11-3_x64-3.2.ipk
Collected errors:
 * wfopen: //opt/lib/opkg/info/zlib.control: Permission denied.
 * extract_archive: Cannot create symlink from ./opt/lib/libz.so to 'libz.so.1': Permission denied.
 * extract_archive: Cannot create symlink from ./opt/lib/libz.so.1 to 'libz.so.1.2.11': Permission denied.
 * wfopen: /opt/lib/libz.so.1.2.11: Permission denied.
 * pkg_write_filelist: Failed to open //opt/lib/opkg/info/zlib.list: Permission denied.
 * opkg_install_pkg: Failed to extract data files for zlib. Package debris may remain!
 * opkg_install_cmd: Cannot install package gcc.
 * opkg_conf_write_status_files: Can't open status file //opt/lib/opkg/status: Permission denied.
 * opkg_conf_write_status_files: Can't open status file /opt/tmp//opt/lib/opkg/status: Permission denied.
[Iwao@TS253D ~]$ 

QNAP NAS ssh 接続 opkg
QNAP NAS opkg install gcc
sudo -i としても入れない.方法がわからなかったので admin で入ることに.

C:\Users\Iwao>ssh -l Iwao ts253d
Iwao@ts253d's password:
[Iwao@TS253D ~]$ sudo -i
Password:
Iwao is not in the sudoers file.  This incident will be reported.
[Iwao@TS253D ~]$
[Iwao@TS253D ~]$
[Iwao@TS253D ~]$ exit
logout
Connection to ts253d closed.

C:\Users\Iwao>ssh -l admin ts253d
admin@ts253d's password:
[~] #
[~] #
[~] #
[/opt/bin] # opkg install gcc  
Installing gcc (7.4.0-5) to root...
Downloading http://bin.entware.net/x64-k3.2/gcc_7.4.0-5_x64-3.2.ipk
Installing zlib (1.2.11-3) to root...
Downloading http://bin.entware.net/x64-k3.2/zlib_1.2.11-3_x64-3.2.ipk
Installing libiconv-full (1.11.1-4) to root...
Downloading http://bin.entware.net/x64-k3.2/libiconv-full_1.11.1-4_x64-3.2.ipk
Installing libintl-full (0.19.8.1-2) to root...
Downloading http://bin.entware.net/x64-k3.2/libintl-full_0.19.8.1-2_x64-3.2.ipk
Installing libbfd (2.27-1) to root...
Downloading http://bin.entware.net/x64-k3.2/libbfd_2.27-1_x64-3.2.ipk
Installing libopcodes (2.27-1) to root...
Downloading http://bin.entware.net/x64-k3.2/libopcodes_2.27-1_x64-3.2.ipk
Installing objdump (2.27-1) to root...
Downloading http://bin.entware.net/x64-k3.2/objdump_2.27-1_x64-3.2.ipk
Installing ar (2.27-1) to root...
Downloading http://bin.entware.net/x64-k3.2/ar_2.27-1_x64-3.2.ipk
Installing binutils (2.27-1) to root...
Downloading http://bin.entware.net/x64-k3.2/binutils_2.27-1_x64-3.2.ipk
Configuring zlib.
Configuring libiconv-full.
Configuring libintl-full.
Configuring libbfd.
Configuring libopcodes.
Configuring objdump.
Configuring ar.
Configuring binutils.
Configuring gcc.
There are no *-dev packages in Entware(with few exceptions)!
Please install headers as described in the wiki:
https://github.com/Entware/Entware/wiki
[/opt/bin] # 

QNAP NAS admin opkg install gcc

https://jml.mish.work/index.php/various/nas/qnap-nas.html

Is this 投稿 useful? Useful Useless 1 of 1 people say this 投稿 is useful.

NAS 日本語ソースのコンパイル

Synology NAS と違い iconv が存在するので,コンパイルの指定で試してみた.
が,うまく動作しない.

Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/MsgStr/cc_ml_1 $ which iconv
/usr/bin/iconv
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/MsgStr/cc_ml_1 $ g++ -Wall cc_ml_1.cpp -finput-charset=SJIS-WIN
cc1plus: error: conversion from SJIS-WIN to UTF-8 not supported by iconv
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/MsgStr/cc_ml_1 $ g++ -Wall cc_ml_1.cpp -finput-charset=SJIS
cc1plus: error: conversion from SJIS to UTF-8 not supported by iconv
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/MsgStr/cc_ml_1 $ iconv -f SJIS cc_ml_1.cpp  > u8_ml_1.cpp
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/MsgStr/cc_ml_1 $ g++ -Wall u8_ml_1.cpp
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/MsgStr/cc_ml_1 $ ./a.out
名称 3
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/MsgStr/cc_ml_1 $         

iconv -f  SJIS  , g++
結局 Synology NAS と同様で,予め UTF-8 に変換しておく必要がある.


iconv -f SJIS-WIN SJ_file.txt ができなかった.
iconv -f CP932 SJ_file.txt ならば通る.
他にも iconv -f SJIS なら通るが,Fedora ではダメだったので CP932 を使用することに.


Windows 上で管理しているソースは,私が作成した次のツールで変換しています.
https://i–tools.blogspot.com/2020/02/copycc202001.html

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

AS5202T セットアップ

先日届いていた AS5202T .それ用の HDD を注文したら納期がかかるみたい.
それで手元にあった WD Red 1TB を取り付けてセットアップしてみた.
NAS に取り付ける時,斜めになってしまうことがあるので注意が必要.


最初に ASUSTOR コントロールセンター をダウンロードして PC にインストール.
ASUSTOR Control Center
「初期化されていません」を押して,画面の指示に従って ADM をインストール.
AS5202T 初期化 1
AS5202T 初期化 2
AS5202T 初期化 3
AS5202T Portal
Web もセットアップされていた.
AS5202T web


NAS が動作することは確認できたので,メモリを 8GB に取り換え.
電源を入れると,一番上の青いランプが点灯,システムステータスのランプが点滅のままでうまく起動しない.
通常であればネットワークやハードディスクのランプが点滅や点灯するはず.
もう一度メモリを外して元の 2GB の状態にするとうまく起動する.
追加で 1 枚さして 6GB でもうまく起動.
2GB も交換して 4GB x 2 の状態で試すとうまく起動した.
メモリの挿し方が甘かった?


今回この機種を追加した目的の一つが VirtualBox .
App Central から VirtualBox と VirtualBox Extension Pack をインストール.
追加された VirtualBox アイコンをクリックすると新しくブラウザのウィンドウが開く.
AS5202T VirtualBox ログイン
この時のログインの ID がわからなかったが admin と admin で入れる.
https://www.asustor.com/en/online/College_topic?topic=249
https://forest.watch.impress.co.jp/docs/shseri/siranas/1023605.html
https://mdw-note.net/tips/setting-virtualbox-as3102t/
以前 PC で作成した Win10_LTSC.vdi を NAS の Public/VHD/Win10_LTSC にコピー.
それを使用する様に VirtualBox の仮想マシンを追加.
追加した仮想マシンを起動すると右上にプレビューが表示されている.
AS5202T VirtualBox
この仮想マシンは VNC サーバの設定がしてあるので,VNC ビューアから接続.
AS5202T VirtualBox VNC 接続


もう一つ確認したのが gcc .
App Central で entware を追加.
ASUSTOR NAS App Central 「entware」

C:\Users\Iwao\AppData\Local\Temp>ssh -l Iwao -p 22 192.168.1.75
Password:
Iwao@AS5202T:/volume1/home/Iwao $ gcc
-sh: gcc: not found
Iwao@AS5202T:/volume1/home/Iwao $ opkg
opkg must have one sub-command argument
usage: opkg [options...] sub-command [arguments...]
where sub-command is one of:

Package Manipulation:
        update                  Update list of available packages
        upgrade <pkgs>          Upgrade packages
        install <pkgs>          Install package(s)
        configure <pkgs>        Configure unpacked package(s)
        remove <pkgs|regexp>    Remove package(s)
        flag <flag> <pkgs>      Flag package(s)
         <flag>=hold|noprune|user|ok|installed|unpacked (one per invocation)

Informational Commands:
        ...

Iwao@AS5202T:/volume1/home/Iwao $ opkg install gcc
Installing gcc (7.4.0-5) to root...
Downloading http://bin.entware.net/x64-k3.2/gcc_7.4.0-5_x64-3.2.ipk
Installing zlib (1.2.11-3) to root...
Downloading http://bin.entware.net/x64-k3.2/zlib_1.2.11-3_x64-3.2.ipk
Installing libiconv-full (1.11.1-4) to root...
Downloading http://bin.entware.net/x64-k3.2/libiconv-full_1.11.1-4_x64-3.2.ipk
Installing libintl-full (0.19.8.1-2) to root...
Downloading http://bin.entware.net/x64-k3.2/libintl-full_0.19.8.1-2_x64-3.2.ipk
Installing libbfd (2.27-1) to root...
Downloading http://bin.entware.net/x64-k3.2/libbfd_2.27-1_x64-3.2.ipk
Installing libopcodes (2.27-1) to root...
Downloading http://bin.entware.net/x64-k3.2/libopcodes_2.27-1_x64-3.2.ipk
Installing objdump (2.27-1) to root...
Downloading http://bin.entware.net/x64-k3.2/objdump_2.27-1_x64-3.2.ipk
Installing ar (2.27-1) to root...
Downloading http://bin.entware.net/x64-k3.2/ar_2.27-1_x64-3.2.ipk
Installing binutils (2.27-1) to root...
Downloading http://bin.entware.net/x64-k3.2/binutils_2.27-1_x64-3.2.ipk
Configuring zlib.
Configuring libiconv-full.
Configuring libintl-full.
Configuring libbfd.
Configuring libopcodes.
Configuring objdump.
Configuring ar.
Configuring binutils.
Configuring gcc.
There are no *-dev packages in Entware(with few exceptions)!
Please install headers as described in the wiki:
https://github.com/Entware/Entware/wiki
Iwao@AS5202T:/volume1/home/Iwao $
Iwao@AS5202T:/volume1/home/Iwao $ gcc
/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
Iwao@AS5202T:/volume1/home/Iwao $ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/lto-wrapper
Target: x86_64-openwrt-linux-gnu
Configured with: /media/ware3/Entware.2020.01/build_dir/target-x86_64_glibc-2.27/gcc-7.4.0/configure --target=x86_64-openwrt-linux --host=x86_64-openwrt-linux --build=x86_64-pc-linux-gnu --program-prefix= --program-suffix= --prefix=/opt --exec-prefix=/opt --bindir=/opt/bin --sbindir=/opt/sbin --libexecdir=/opt/lib --sysconfdir=/opt/etc --datadir=/opt/share --localstatedir=/opt/var --mandir=/opt/man --infodir=/opt/info --disable-nls 'CXXFLAGS_FOR_TARGET=-g -O2 -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS' --build=x86_64-pc-linux-gnu --host=x86_64-openwrt-linux-gnu --target=x86_64-openwrt-linux-gnu --enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 7.4.0' --enable-shared --enable-__cxa_atexit --with-default-libstdcxx-abi=gcc4-compatible --enable-target-optspace --with-gnu-ld --with-specs='-Wl,-rpath=/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux-x86-64.so.2' --with-boot-ldflags='static-libstdc++ -static-libgcc -Wl,-rpath=/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux-x86-64.so.2' --disable-nls --disable-libsanitizer --disable-libvtv --disable-libcilkrts --disable-libmudflap --disable-libmpx --disable-multilib --disable-libgomp --disable-libquadmath --disable-libssp --disable-decimal-float --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/opt --libexecdir=/opt/lib --with-local-prefix=/opt --with-stage1-ldflags='-lstdc++ -Wl,-rpath=/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux-x86-64.so.2' --with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 7.4.0 (OpenWrt GCC 7.4.0)
COMPILER_PATH=/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/:/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/
LIBRARY_PATH=/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/:/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/:/lib/../lib64/:/usr/lib/../lib64/:/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 /volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/collect2 -plugin /volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/liblto_plugin.so -plugin-opt=/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccm1Y6FA.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/crt1.o /volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/crti.o /volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/crtbegin.o -L/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0 -L/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc -L/lib/../lib64 -L/usr/lib/../lib64 -L/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/../../.. -rpath=/opt/lib --dynamic-linker=/opt/lib/ld-linux-x86-64.so.2 -lgcc_s -lc -lgcc_s /volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/crtend.o /volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/crtn.o
/volume1/.@plugins/AppCentral/entware/opt/bin/../lib/gcc/x86_64-openwrt-linux-gnu/7.4.0/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
Iwao@AS5202T:/volume1/home/Iwao $
Iwao@AS5202T:/volume1/home/Iwao $ ll
total 12
drwxr-xr-x    2 Iwao     users       4.0K Mar 16 18:27 ./
drwxr-xr-x    4 root     root        4.0K Mar 16 15:19 ../
-rw-------    1 Iwao     users        100 Mar 16 18:43 .ash_history
Iwao@AS5202T:/volume1/home/Iwao $ mkdir test
Iwao@AS5202T:/volume1/home/Iwao $ cd test
Iwao@AS5202T:/volume1/home/Iwao/test $ cat > test.cpp
int     main    ()
{
        return  2 ;
        }
Iwao@AS5202T:/volume1/home/Iwao/test $ cat test.cpp
int     main    ()
{
        return  2 ;
        }
Iwao@AS5202T:/volume1/home/Iwao/test $ ls
test.cpp
Iwao@AS5202T:/volume1/home/Iwao/test $ g++ test.cpp
Iwao@AS5202T:/volume1/home/Iwao/test $ ./a.out
Iwao@AS5202T:/volume1/home/Iwao/test $ echo $?
2
Iwao@AS5202T:/volume1/home/Iwao/test $ echo $?
0
Iwao@AS5202T:/volume1/home/Iwao/test $


https://jml.mish.work/various/nas/asustor.html

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

NAS g++ で a.out が作成されない?

warning はあるが,エラーの表示はない状態まで修正して g++ .

Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ g++ t_calc.cpp -Wall
In file included from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/_gcc/V2_FuncA.hxx:1:0,
                 from Calc_16.cpp:46,
                 from t_calc.cpp:29:
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx: In constructor 'vd2_arc::vd2_arc()':
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx:28:9: warning: 'vd2_arc::tc' will be initialized after [-Wreorder]
  double tc ;
         ^~
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx:27:9: warning:   'double vd2_arc::ts' [-Wreorder]
  double ts ;
         ^~
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx:23:2: warning:   when initialized here [-Wreorder]
  vd2_arc () : lr(0) , tc(0) , ts(0) {}
  ^~~~~~~
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx: In function 'Vd2 get_point_pie(const Vd2&, const Vd2&, double, double)':
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx:263:6: warning: variable 'lm' set but not used [-Wunused-but-set-variable]
  Vd2 lm = (le-ls) / 2 ;
      ^~
In file included from t_calc.cpp:29:0:
Calc_16.cpp: In member function 'virtual int VarCnv::SetError(LPCTSTR, ...)':
Calc_16.cpp:1319:7: warning: variable 'cnt' set but not used [-Wunused-but-set-variable]
  int  cnt ;
       ^~~
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ ls
Calc_16.BAK  Calc_16.cpp  Calc_16.hpp  t_calc.BAK  t_calc.cpp  t_calc.dsp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ g++ t_calc.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ ls
Calc_16.BAK  Calc_16.cpp  Calc_16.hpp  t_calc.BAK  t_calc.cpp  t_calc.dsp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ ll
total 248
drwxrwxrwx+  2 Iwao users   4096 Feb  6 11:46 .
drwxrwxrwx+ 16 Iwao users   4096 Feb  6 10:18 ..
-rwxrwxrwx+  1 Iwao users 103036 Feb  6 11:45 Calc_16.BAK
-rwxrwxrwx+  1 Iwao users 103032 Feb  6 11:46 Calc_16.cpp
-rwxrwxrwx+  1 Iwao users  11608 Feb  5 18:53 Calc_16.hpp
-rwxrwxrwx+  1 Iwao users   2756 Feb  6 11:18 t_calc.BAK
-rwxrwxrwx+  1 Iwao users   2420 Feb  6 11:43 t_calc.cpp
-rwxrwxrwx+  1 Iwao users   4420 Feb  5 16:39 t_calc.dsp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ 

なのに a.out が作成されない.
Raspberry Pi で同様に動かすと

pi@raspberrypi:~/projects/t_calc $ g++ t_calc.cpp
In file included from t_calc.cpp:29:
Calc_16.cpp: In function ‘int ExpDel_Bracket1(TCHAR*, size_t, int, int, char)’:
Calc_16.cpp:2152:6: error: ‘_tcspbrk’ was not declared in this scope
  if (_tcspbrk(val,bracket)==NULL){ return FALSE ; } // ���ʂ����݂��Ȃ����͉������Ȃ�
      ^~~~~~~~
Calc_16.cpp:2152:6: note: suggested alternative: ‘wcspbrk’
  if (_tcspbrk(val,bracket)==NULL){ return FALSE ; } // ���ʂ����݂��Ȃ����͉������Ȃ�
      ^~~~~~~~
      wcspbrk
Calc_16.cpp:2161:21: error: ‘_tcsrchr’ was not declared in this scope
  LPTSTR equStartB = _tcsrchr(tmpLeft,startB) ; // �ŏ��� ')' �ɑΉ����� '(' �̈ʒu�����߂�
                     ^~~~~~~~
Calc_16.cpp:2161:21: note: suggested alternative: ‘_tcschr’
  LPTSTR equStartB = _tcsrchr(tmpLeft,startB) ; // �ŏ��� ')' �ɑΉ����� '(' �̈ʒu�����߂�
                     ^~~~~~~~
                     _tcschr
pi@raspberrypi:~/projects/t_calc $ 

どうも ShiftJIS のコメントが邪魔してかエラーが表示されてないだけみたい.
Raspberry Pi でコンパイルするとエラーが表示される
未定義となっているので正しく宣言して対応.


次は warning .

.../v2_funca.hxx:28:9: warning: 'vd2_arc::tc' will be initialized after [-Wreorder]      double tc ;
.../v2_funca.hxx:27:9: warning:   'double vd2_arc::ts' [-Wreorder]                       double ts ;
.../v2_funca.hxx:23:2: warning:   when initialized here [-Wreorder]                      vd2_arc () : lr(0) , tc(0) , ts(0) {}

これは,クラス内の変数の宣言と初期化の順番が異なる場合のものらしい.
もう一つの [-Wunused-but-set-variable] は戻り値を使用していないもの.

warning: variable 'lm' set but not used [-Wunused-but-set-variable]

変数を削除して対応.


前後するが 先日のツール で ShiftJIS のソースを UTF-8 に.

Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ cd test_sj/
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ ls
Calc_16.cpp  Calc_16.hpp  t_calc.BAK  t_calc.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ g++ t_calc.cpp -Wall
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ ll
total 132
drwxrwxrwx+ 2 Iwao users   4096 Feb  6 16:39 .
drwxrwxrwx+ 3 Iwao users   4096 Feb  6 16:38 ..
-rwxrwxrwx+ 1 Iwao users 103036 Feb  6 14:41 Calc_16.cpp
-rwxrwxrwx+ 1 Iwao users  11608 Feb  5 18:53 Calc_16.hpp
-rwxrwxrwx+ 1 Iwao users   1821 Feb  6 16:04 t_calc.BAK
-rwxrwxrwx+ 1 Iwao users   1841 Feb  6 16:39 t_calc.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ g++ t_calc.cpp -Wall -finput-charset=SJIS
cc1plus: error: conversion from SJIS to UTF-8 not supported by iconv
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ g++ t_calc.cpp -Wall
In file included from t_calc.cpp:27:0:
Calc_16.cpp: In function 'int ExpDel_Bracket1(TCHAR*, size_t, int, int, char)':
Calc_16.cpp:2152:26: error: '_tcspbrk' was not declared in this scope
  if (_tcspbrk(val,bracket)==NULL){ return FALSE ; } // 括弧が存在しない時は何もしない
                          ^
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ ll
total 136
drwxrwxrwx+ 3 Iwao users   4096 Feb  6 16:46 .
drwxrwxrwx+ 3 Iwao users   4096 Feb  6 16:38 ..
-rwxrwxrwx+ 1 Iwao users 108716 Feb  6 14:41 Calc_16.cpp
-rwxrwxrwx+ 1 Iwao users  12170 Feb  5 18:53 Calc_16.hpp
drwxrwxrwx+ 2 Iwao users   4096 Feb  6 16:45 org
-rwxrwxrwx+ 1 Iwao users   1841 Feb  6 16:39 t_calc.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$

エラーが表示される.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

漢字を含むソースのテスト

’90 年代前半の頃は JIS と シフトJIS のソースを扱っていた.
そのプロジェクトの最初の頃は,ターゲット環境のみでソースを管理していた.
0x1c 0x2d 漢字 0x1c 0x2e の形式.wiki 漢字シフトコード
途中からソース管理は PC-9801DA などに移行してシフトJIS になった.
ターゲット環境に移す時,ソースのコピーとシフトJIS から JIS への変換を行っていた.


Linux 環境を意識し始めてから新規に書いた共通のコードは 7 ビットの範囲にしている.
Windows AP であれば rc ファイルの STRINGTABLE が使用できるが,これにあたるものをどうするか?
まず一番簡単な方法の漢字を含むソースでの動作をテストしてみた.
この中の ccc(const char* s) の部分はまだ暫定的なコードで,登録されたテーブルから対応する JPN を求めるもの.

#include	<clocale>
#include	<iostream>
#include	"i_define.hxx"
#include	"_tdefine.hxx"
#include	"ccc_mlg.hxx"

bool	test	(void)
{
	ccc_mlg*	cm = ::get_ccc_mlg() ;
	{
		ccc_mlg_1	cm_1 ;	cm_1.Name = _T("Name_1") ;	cm_1.JPN = _T("名称 1") ;
		ccc_mlg_1	cm_2 ;	cm_2.Name = _T("Name_2") ;	cm_2.JPN = _T("名称 2") ;
		ccc_mlg_1	cm_3 ;	cm_3.Name = _T("Name_3") ;	cm_3.JPN = _T("名称 3") ;
		ccc_mlg_1	cm_4 ;	cm_4.Name = _T("Name_4") ;	cm_4.JPN = _T("名称 4") ;
		ccc_mlg_1	cm_5 ;	cm_5.Name = _T("Name_5") ;	cm_5.JPN = _T("名称 5") ;
		cm->push_back(cm_1) ;
		cm->push_back(cm_2) ;
		cm->push_back(cm_3) ;
		cm->push_back(cm_4) ;
		cm->push_back(cm_5) ;
		}
	std::tout << ccc("Name_3") << std::endl ;
	return	true ;
	}

int _tmain(int argc, TCHAR* argv[])
{
	_tsetlocale(LC_ALL,_T("")) ;
	test() ;
	return 0 ;
	}

gcc 漢字 shiftjis」で検索すると -finput-charset で文字コードを指定できるとある.

pi@raspberrypi:~/projects/cc_ml_1 $ g++ cc_ml_1.cpp 
pi@raspberrypi:~/projects/cc_ml_1 $ ./a.out 
���� 3
pi@raspberrypi:~/projects/cc_ml_1 $ g++ -finput-charset=SJIS-WIN cc_ml_1.cpp 
pi@raspberrypi:~/projects/cc_ml_1 $ ./a.out 
名称 3
pi@raspberrypi:~/projects/cc_ml_1 $ 

g++ -finput-charset=SJIS-WIN
-finput-charset=SJIS ではよくわからないエラーになる.
g++ -finput-charset=SJIS
cp932 でも良さそう.


Synology NAS DS116 は g++ の-finput-charset の指定では変換できないみたい.

Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ g++ cc_ml_1.cpp -Wall
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ ll
total 72
drwxrwxrwx+  3 Iwao users  4096 Jan 16 22:01 .
drwxrwxrwx+ 10 Iwao users  4096 Jan 16 21:36 ..
-rwxrwxrwx   1 Iwao users 50452 Jan 16 22:01 a.out
drwxrwxrwx+  2 Iwao users  4096 Jan 16 21:53 bak
-rwxrwxrwx+  1 Iwao users  2001 Jan 16 22:00 cc_ml_1.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ ./a.out
 3
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ uconv -f sjis cc_ml_1.cpp > dd.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ g++ dd.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ ./a.out
名称 3
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ g++ -finput-charset=SJIS cc_ml_1.cpp
cc1plus: error: conversion from SJIS to UTF-8 not supported by iconv
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ g++ -finput-charset=sjis cc_ml_1.cpp
cc1plus: error: conversion from sjis to UTF-8 not supported by iconv
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ iconv
-sh: iconv: command not found
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Linux 文字コード変換のコード

iconv を使用した方法

std::string	SJIS_to_UTF8	(const std::string& sj_str)
{
	tstring	u8_str ;
	iconv_t	icd = ::iconv_open("UTF8","Shift_JIS") ;
	if (icd == (iconv_t)-1) {
		u8_str = ::iconv_SJIS_UTF8(sj_str) ;
		}
	else {
		{
			size_t	sj_size = sj_str.length() ;
			size_t	u8_size = sj_str.length()*3 + 1024 ;
			u8_str.resize(u8_size) ;
			char*	sj_ptr = (char*)(&sj_str[0]) ;
			char*	u8_ptr = (char*)(&u8_str[0]) ;
			::iconv(icd,&sj_ptr,&sj_size,&u8_ptr,&u8_size) ;
			}
		::iconv_close(icd) ;
		}
	return	u8_str.c_str() ;
	}

iconv,uconv の部分

#define	cmd_iconv		_T("iconv")		//	linux
#define	cmd_uconv		_T("uconv")		//	DS116
 
bool	exec_x_conv	(const tstring& s_j_name,const tstring& u_8_name)
{
	tstring	sj_name = ::QuotM_Add_Auto(s_j_name) ;
	tstring	u8_name = ::QuotM_Add_Auto(u_8_name) ;
	tstring	param = _T(" -f sjis -t utf8 ") + sj_name + _T(" -o ") + u8_name ;
	if (::which( cmd_iconv)) {
		tstring	 exe_iconv = cmd_iconv	_T(" ") + param ;
		_tsystem(exe_iconv.c_str()) ;
		return	true ;
		}
	if (::which( cmd_uconv)) {
		tstring	 exe_uconv = cmd_uconv	_T(" ") + param ;
		_tsystem(exe_uconv.c_str()) ;
		return	true ;
		}
	return	false ;
	}
 
std::string	iconv_SJIS_UTF8(const std::string& sj_str)
{
	tstring	tmp_path = ::Get_i_Tools_tmp_date() ;
	tstring	now_str  = ::Now_Format(_T("%M%S")) ;
	tstring	s_j_name = ::Path_AddLastSP(tmp_path) + _T("sj_") + now_str + _T(".txt") ;
	tstring	u_8_name = ::Path_AddLastSP(tmp_path) + _T("u8_") + now_str + _T(".txt") ;
		s_j_name = ::CreateUniqueEmpty(s_j_name.c_str()) ;
		u_8_name = ::CreateUniqueEmpty(u_8_name.c_str()) ;
	std::string	u8_str ;
	{
		v_char	v_c_u8 ;
		v_char	v_c_sj = ::To_v_char(sj_str.c_str()) ;
				 ::v_c_SaveText(s_j_name.c_str(),v_c_sj) ;
		{
				 ::exec_x_conv(s_j_name,u_8_name) ;
			}
		v_c_u8 = ::v_c_Load (u_8_name.c_str()) ;
		u8_str = ::To_tstring( v_c_u8   ).c_str() ;
		}
	return	u8_str.c_str() ;
	}

Fedora  iconv コマンドでの変換


うまく置き換わっていない文字があった.
‘~'(0x7e) が ‘‾'(0x203e) になってしまっていた.
他にも ‘\'(0x5c) が ‘¥'(0xa5) .
http://ossforum.jp/jossfiles/Linux_SJIS_Support.pdf
幾つか違う文字があるようで,iconv の -f sjis を SJIS-WIN でうまくいった.

	tstring	i_param = _T(" -f SJIS-WIN -t utf8 ") + sj_name + _T(" -o ") + u8_name ;
	tstring	u_param = _T(" -f sjis     -t utf8 ") + sj_name + _T(" -o ") + u8_name ;

2020/04/30 ASUSTOR NAS に対応
text_gnc.hxx exec_ic.hxx

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Linux で文字コードの変換

Windows での文字コードの変換部分は MultiByteToWideChar,WideCharToMultiByte でうまく機能している.

 exe \ 入力 シフトJIS UTF-16 UTF-8
_UNICODE → WideChar そのまま → WideChar(CP_UTF8)
_MBCS そのまま → MultiByte → WideChar(CP_UTF8) → MultiByte

MultiByteToWideCharWideCharToMultiByte の使い方は 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:~$
DS116 で uconv -L


iconv_open で失敗した場合,iconv コマンドまたは uconv コマンドとするか?


Linux 文字コード変換のコード


2022/07/15
SynoCli File Tools v2.6-16 で iconv が追加された.
SynoCli File Tools などのインストール方法は次の所に書いています.
https://dev.mish.work/wordpress/2022/06/15/ds116-entware/

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.