| 例のやつを使ったのですね (^^)
桐でURLエンコードはShift_JISだと次のコードでどうだったかな?
ずいぶん前のものなので良く覚えていませんけど (^^;
---
名札 メイン
*
手続き定義開始 変換前::フォーカス取得(文字列 &喪失オブジェクト名)
method @フォーム.更新モード設定(2)
手続き定義終了
手続き定義開始 変換前::ソース値更新()
/*call UrlEncode(&変換前,&変換後)
/*call UrlDecode(&変換前,&変換後)
/*ウィンドウ更新 -1
手続き定義終了
proc UrlDecode(str &Source, refer str &Result)
cond (.not&Source) Return
var long {&SourceLength, &i, &Hex}
var str {&Str, &Str1, &Str2, &Str3, &Str4, &dStr}
&SourceLength = #l(&Source), &Result=#u
for &i = 1, &SourceLength, 1
&Str = #sstr(&Source, &i, 1)
if (&Str = "+")
&Result = &Result + " "
else if ((&Str = "%") .and (&i+2 =< &SourceLength))
&Str1 = #sstr(&Source, &i+1, 1) \
,&Str2 = #sstr(&Source, &i+2, 1)
&Hex = #h(&Str1+&Str2)
if ( (#h("00") <= &Hex .and &Hex <= #h("80")) \
.or (#h("A0") <= &Hex .and &Hex <= #h("DF")))
&dStr=#sj(&Hex)
&Result = &Result + &dStr
&i = &i + 2
else if ( (#h("81") <= &Hex .and &Hex <= #h("9F")) \
.or (#h("E0") <= &Hex .and &Hex <= #h("FF")))
if ( &i+5 =< &SourceLength \
.and #sstr(&Source, &i+3, 1) = "%")
&Str3 = #sstr(&Source, &i+4, 1) \
,&Str4 = #sstr(&Source, &i+5, 1)
&Hex = #h(&Str1+&Str2+&Str3+&Str4)
&dStr=#sj(&Hex)
&Result = &Result + &dStr
&i = &i + 5
else if (&i+3 =< &SourceLength)
&Str3 = #str(#h(#sj(#sstr(&Source, &i+3, 1))))
&Hex = #h(&Str1+&Str2+&Str3)
&dStr=#sj(&Hex)
&Result = &Result + &dStr
&i = &i + 3
else
&Result = &Result + &Str + &Str1 + &Str2
&i = &i + 2
end
else
&Result = &Result + &Str + &Str1 + &Str2
&i = &i + 2
end
else
&Result = &Result + &Str
end /* if */
end /* for */
end /*UrlDecode*/
proc UrlEncode(str &Source, refer str &Result)
cond (.not&Source) Return
var long {&SourceSize ,&i ,&Asc,&HexLength, &Count}
var str {&Single, &Hex}
&SourceSize = #l(&Source), &Result=#u
for &i = 1, &SourceSize, 1
&Single = #sstr(&Source, &i, 1)
&Asc= #sj(&Single)
if (&Asc = 32)
&Result = &Result + "+"
else if ( (&Asc >= 64 .and &Asc <= 90) \
.or (&Asc >= 97 .and &Asc <= 122) \
.or (&Asc >= 48 .and &Asc <= 57) \
.or &Asc = 42 .or &Asc = 45 \
.or &Asc = 46 .or &Asc = 95)
&Result = &Result + &Single
else
&Hex = #h(&Asc)
&HexLength = #l(&Hex)
if (&HexLength = 4)
&Result = &Result + "%"
&Result = &Result +#sstr(&Hex, 1, 2)
&Result = &Result + "%"
&Result = &Result +#sstr(&Hex, 3, 2)
else if (&HexLength = 2)
&Result = &Result + "%"
&Result = &Result + &Hex
else
&Result = &Result + "%"
&Result = &Result + "0"
&Result = &Result + &Hex
end /* if */
end /* if */
end /* for */
end /*UrlEncode*/
proc 描画更新()
ウィンドウ更新 -1
end
---
|