iconv.lsp

Module index

source download

Module: iconv.lsp

Yet Another Iconv Library

Version: 0.5 初版
Version: 0.6 Windows(DLL)でも使えるように
Version: 0.7 関数を増やした
Version: 0.8 変換後のNULL文字に対応したつもり
Version: 0.8b newlisp_sjisでのバッファあふれ修正
Version: 0.8c Rename iconv-handler -> call-with-iconv-descriptor
Version: 0.8d a few modified.
Version: 0.9 SunOS 5.10 sparc にて動作テスト。
ロード時にIconv:initを呼び出すように変更 Version: 0.9b Tested FreeBSD 8.1
Version: 0.9c Tested CYGWIN_NT-5.1
Author: KOBAYASHI Shigeru , 2009-2011
Location: https://raw.github.com/gist/242697
Example:
 (load "iconv.lsp")
 ;(Iconv:init)

 $ echo -n 'おはよう、朝だよ!' | iconv -t EUC-JP > euc.txt
 (write-file "euc.txt" (Iconv:encode "おはよう、朝だよ!" "EUC-JP"))

 $ cat euc.txt | iconv -f EUC-JP
 (Iconv:decode (read-file "euc.txt") "EUC-JP")
 => "おはよう、朝だよ!"

 (let ((str "\xa3\xb1\xa1\xdc\xa3\xb1\xa1\xe1\xa3\xb2"))
   (Iconv:decode str "EUC-JP"))
 => "1+1=2"

 (define (my-unicode str)
   (Iconv:convert str "UTF-8" "UTF-32LE"))
 (my-unicode "new") => "n\000\000\000e\000\000\000w\000\000\000"

 (define (my-utf8 str)
   (Iconv:convert str "UTF-32LE" "UTF-8"))
 (my-utf8 (unicode "new")) => "new\000"
 (my-utf8 (my-unicode "new")) => "new"
@KnownBugs 端末以外から利用すると正しく表示されないかもしれない @TODO (! "iconv --list") list all known coded character sets メモリ不足を避けるために分割して変換する関数も欲しい 変換用に用意するバッファのサイズが適当過ぎる ポインタ変数の分かりやすい表記方法があれば取り込みたい (p_str, *str) iconv/libiconv を区別する方法 エラーを投げるよりも無理矢理変換する方が良い? NOTE: - KaoriYa.net provides "iconv.dll" - GnuWin32 provides "libiconv2.dll"

§

Iconv:init

syntax: (Iconv:init [library-name])

return: true (but not meaningful)

Loadup iconv library functions.

Example:
 (Iconv:init)
 (Iconv:init "C:/usr/lib/libiconv.dll") ; specifies library pathname


§

unwind-protect

syntax: (unwind-protect protected-form cleanup-form*)

return: the value of protected-form.

Location: http://www.lispworks.com/documentation/HyperSpec/Body/s_unwind.htm
evaluates protected-form and guarantees that cleanup-forms are executed before unwind-protect exits, whether it terminates normally or is aborted by a control transfer of some kind.

§

Iconv:convert

syntax: (Iconv:convert string fromcode tocode)

return: Returns the converted string fromcode to tocode.



§

Iconv:encode

syntax: (Iconv:encode string tocode)

return: Returns the converted string internal to tocode.



§

Iconv:decode

syntax: (Iconv:decode string fromcode)

return: Returns the converted string fromcode to internal.

Shift_JIS EUC-JP ISO-2022-JP UTF-8 ISO-8859-1 ISO-8859-15 WINDOWS-1252

- ∂ -

generated with newLISP  and newLISPdoc