Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8中国語(簡体字)辞書を有効にしてサーバーとして利用したときの下駄記号 #103

Open
tetsuotsukamoto opened this issue Dec 25, 2020 · 1 comment

Comments

@tetsuotsukamoto
Copy link

tetsuotsukamoto commented Dec 25, 2020

こんにちは。もしお時間ありましたらお願いします。

最近 SKK でピンイン (アルファベット) から中国語(簡体字)に変換できる辞書を作成して変換を試しています。
辞書ファイルは以下のレポジトリにある SKK-JISYO.pinyin で、UTF-8 にしております。
https://github.com/tetsuotsukamoto/pinyin

AquaSKK 4.7.3 でもこの辞書は無事使えています。しかし、サーバー機能を有効にしてEmacs (26.1) 上の DDSKK (16.2) から変換すると一部の文字が下駄記号になってしまう現象がみられました。

ご参考のため「AquaSKK」「サーバーを用いていない Emacs + DDSKK」「サーバーを用いている Emacs + DDSKK」の3つのスクリーンショットを添付します。

何度も編集して恐縮です...これはそもそも、SKKサーバーがずっとEUC-JPを前提として用いられてきたので仕方ないのかもしれませんが、EUC-JPでは日本語と中国語は共存できないことにも関係するかと思います。サーバー側としては、応急的にはEUC-JP系で用いることができない文字を除いていただくのも一手かもしれませんが、将来的にはUTF-8などで通信できればクライアント側での対応で解決可能かもしれない、と感じました。

AquaSKK

Emacs no server

Emacs with AquaSKK server

@NaokiMatsuzaki
Copy link

もともとSKKServプロトコルではEUC-JPを使用することになっており、AquaSKKもDDSKKもSKKサーバではEUC-JPを使用しているため、サーバ側とクライアント側の双方でUTF-8を使用するように変える必要があります。下記の手順を試したところ、DDSKK から AquaSKK の SKK-JISYO.pinyin を使っても文字化けしないようになりましたのでご報告します。

サーバ側(AquaSKK)
ver. 4.7.3 を元に1行変更してビルドしたところ、UTF-8からEUC-JPに変換する処理を飛ばしてUTF-8のまま出力するようになりました。

--- a/src/engine/skkserv/skkserv.cpp
+++ b/src/engine/skkserv/skkserv.cpp
@@ -121,7 +121,7 @@ void* skkserv::worker(void* arg) {
}

        SKKBackEnd::theInstance().Find(entry, result);

- std::string candidates = jconv::eucj_from_utf8(result.ToString(true));
+ std::string candidates = result.ToString(true);
if(!candidates.empty()) {
session << '1' << candidates << std::endl;
} else {

クライアント側(DDSKK)
yaskkserv2を参考に .skk に設定を追加したところ、UTF-8を使用するようになりました。

下記のように init.el などで ddskk 側のふるまいを変更すると UTF-8 dictionary を使用できます 6。

(defun skk-open-server-decoding-utf-8 ()
"辞書サーバと接続する。サーバープロセスを返す。 decoding coding-system が euc ではなく utf8 となる。"
(unless (skk-server-live-p)
(setq skkserv-process (skk-open-server-1))
(when (skk-server-live-p)
(let ((code (cdr (assoc "euc" skk-coding-system-alist))))
(set-process-coding-system skkserv-process 'utf-8 code))))
skkserv-process)
(setq skk-mode-hook
'(lambda()
(advice-add 'skk-open-server :override 'skk-open-server-decoding-utf-8)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants