エンコード・コマンドを使用したファイルの作成

アクション・スクリプト・コマンドの action uses file encoding を使用して、appendfile コマンドおよび createfile until コマンドを使用してファイルを作成するときのエンコードを指定できます。

エンコードは、別のエンコードが指定されるまで有効になります。action uses file encoding コマンドを使用しない場合、appendfile コマンドおよび createfile コマンドではローカル・エンコードでファイルが作成されます。

コマンド構文は次のとおりです。

action uses file encoding encoding [ NoBOM ]

encoding には、ICU が認識できる任意の名前 (ISO-8859-1Shift_JISUTF-8 など) を指定できます。作成後、file オブジェクトは通常の file オブジェクトとして使用でき、ユーザーはテキスト・ファイルに適用可能なあらゆる操作を実行できます。

エンコードの変更をオフにして、ローカル・エンコードを再使用するには、エンコード・キーワードを local に設定します。

UTF エンコード (UTF-8、UTF-16、または UTF-32) のいずれかが encoding の値として指定されている場合、作成されるファイルの先頭に BOM (バイト・オーダー・マーク) が付けられます。クライアントのローカル・エンコードが UTF-8 で、アクションにエンコードが指定されていない場合、アクションを使用して作成されるファイルは、BOM なしの UTF-8 で作成されます。

BOM の追加を抑制するために、encoding の値の後にオプション NoBOM (大/小文字を区別しない) を使用できます。NoBOM オプションは、UTF エンコード (UTF-8、UTF-16、および UTF-32) でのみ有効で、他のエンコード名とともに使用すると無視されます。

次のアクションは、Windows-1253 (ギリシャ語) エンコードを使用してファイルを作成します。
delete "{(client folder of current site as string) & "/__appendfile"}"
action uses file encoding Windows-1253	
appendfile Κόκκινο ου?ανό τη ν?χτα
delete C:\encode_test.txt
move __appendfile C:\encode_test.txt 
次のアクションは 2 つのファイルを作成し、最初のファイルでは Windows-1253 (ギリシャ語) エンコードを使用し、2 番目のファイルではローカル・エンコードを使用します。
delete "{(client folder of current site as string) & "/__appendfile"}"
appendfile Following lines contains Greek language strings 
action uses file encoding Windows-1253 	
appendfile Κόκκινο ου?ανό τη ν?χτα
move __appendfile C:\Greek_test.txt
// switch to local encode
delete "{(client folder of current site as string) & "/__appendfile"}"
appendfile Following lines contains English strings 
action uses file encoding local 
appendfile  Am I writing a local US strings now !
delete C:\tmp\local_test.txt
move __appendfile C:\tmp\local_test.txt
次のアクションは、BOM なしで UTF-8 エンコードを使用してファイルを作成します。
delete "{(client folder of current site as string) & "/__appendfile"}"
action uses file encoding UTF-8 noBOM	
appendfile Hello world !!
delete /tmp/encode_test.txt
move __appendfile /tmp/encode_test.txt