-
詳細
-
作者: qb_dp
-
カテゴリ: FileMaker Custom Function
-
-
参照数: 4073
FileMaker スクリプト:URLから挿入 で、Windowsの場合、プロトコル「file://」や「smb://」を使う場合、日本語(全角混じり)のパスではエラーになります。
以下の式でURLエンコードすればOK。
FileMaker 16以降
%エンコード部分の再帰式は、Shinさんが書いたモノです。
https://fm-aid.com/bbs2/viewtopic.php?pid=50129#p50129
SHIFT-JIS, SHIFT_JIS, エンコード
2021/01/26
接頭辞を $ から $_ へ変更
$_Resultの初期化を追加
- function(関数):
GetUrlEncSJIS( Text )
- Sample input(入力例):
GetUrlEncSJIS( "D:\!TEMP\フォルダー\ドキュメント.txt" )
- Sample output(出力例):
D:\!TEMP\%83%74%83%48%83%8B%83%5F%81%5B\%83%68%83%4C%83%85%83%81%83%93%83%67.txt
- formula(式):
Let(
[
$_Val = Text ;
$_Result="";
$_MAX = Length ( $_Val ) ;
$_n = 1 ;
$_fnc0=
"Case ( $_n > $_MAX ; $_Result ;
Let(
[
$_text=Middle ( $_Val ; $_n ; 1 );
$_Result = $_Result & if(Code ( $_text )>127;
Let(
[
$_txt = HexEncode ( TextEncode ( $_text ; \"shift_jis\" ; 1 ) ) ;
$_pos = Length ( $_txt ) - 1 ;
$_fnc=
\"Case ( $_pos < 0 ; $_txt ;
Let(
[
$_txt = Replace ( $_txt ; $_pos ; 0 ; \\\"%\\\" ) ;
$_pos = $_pos - 2
];
Evaluate($_fnc))
)\"
];
Evaluate($_fnc)
)
;
Middle ( $_Val ; $_n ; 1 )
);
$_n = $_n + 1
];
Evaluate($_fnc0))
)"
];
Evaluate($_fnc0)
)