4D-JUG
Would you like to react to this message? Create an account in a few clicks or log in to continue.

特殊数字とReplace String

2 posters

Go down

特殊数字とReplace String Empty 特殊数字とReplace String

投稿 by osaru 2018-09-02, 3:59 pm

4D v16.3 Hotfix 4
以前のアンガールズ問題と関連なのかもしれませんが、
Code:
$s:="12345678901011121314151617181920"+Char(13)  //半角
$s:=$s+"123456789011121314151617181920"+Char(13)  //全角
$s:=$s+"①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳"+Char(13)  //記号
$s:=$s+"ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ"+Char(13)
$s:=$s+"⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽"+Char(13)
ALERT($s)
$s:=Replace string($s;"①";"(1)")
$s:=Replace string($s;"②";"(2)")
$s:=Replace string($s;"③";"(3)")
$s:=Replace string($s;"④";"(4)")
$s:=Replace string($s;"⑤";"(5)")
$s:=Replace string($s;"⑥";"(6)")
$s:=Replace string($s;"⑦";"(7)")
$s:=Replace string($s;"⑧";"(8)")
$s:=Replace string($s;"⑨";"(9)")
$s:=Replace string($s;"⑩";"(10)")
$s:=Replace string($s;"⑪";"(11)")
$s:=Replace string($s;"⑫";"(12)")
$s:=Replace string($s;"⑬";"(13)")
$s:=Replace string($s;"⑭";"(14)")
$s:=Replace string($s;"⑮";"(15)")
$s:=Replace string($s;"⑯";"(16)")
$s:=Replace string($s;"⑰";"(17)")
$s:=Replace string($s;"⑱";"(18)")
$s:=Replace string($s;"⑲";"(19)")
$s:=Replace string($s;"⑳";"(20)")
ALERT($s)
ALERT(String(Character code("1")))
ALERT(String(Character code("1")))
ALERT(String(Character code("①")))
丸括りの数値文字が、半角数字、全角数字ともにマッチします。これはこういう物なのでしょうか?それとも設定によるものでしょうか?

osaru

投稿数 : 67
登録日 : 2017/08/14

トップに戻る Go down

特殊数字とReplace String Empty Re: 特殊数字とReplace String

投稿 by miyako 2018-09-06, 3:13 pm

Unicodeでは,コレーションと呼ばれるアルゴリズムに基づき,文字同士が『等価』であるかどうかを判別します。Shift_JISなどとは違い,見た目がそっくりでも別の文字(キリル文字のa=U+0430とラテン文字のa=U+0061),反対に文字数や文字コードが別でも実際には同じ文字(ゔ=U+3094と結合濁点と「う」の組み合わせ=U+304C U+3099)があるので,単純に文字コードだけで比較するといろいろと不都合があるので,こうした仕組みは不可欠です。

https://www.slideshare.net/kmiyako/unicodev110

コレーションには,比較的,緩い基準から文字コードで評価する厳格な基準まで,5段階の『レベル』が存在します。4Dは,テキスト比較のデータベース設定が『日本語』に合わされている場合,並び替えや比較演算子の<,>でレベル3(やや厳格/デフォルト),クエリや比較演算子の=,#でレベル2(やや緩い/検索向き)のコレーションで文字列の等価性を判別します。

https://www.slideshare.net/kmiyako/unicodev115

丸文字を例にすると,










1
2
3
4
5
6
7
8
9

レベル3では

1 14 01 05 01 05 00
① 14 01 05 01 df 00
2 16 01 05 01 05 00
② 16 01 05 01 df 00
3 18 01 05 01 05 00
③ 18 01 05 01 df 00
4 1a 01 05 01 05 00
④ 1a 01 05 01 df 00
5 1c 01 05 01 05 00
⑤ 1c 01 05 01 df 00
6 1e 01 05 01 05 00
⑥ 1e 01 05 01 df 00
7 20 01 05 01 05 00
⑦ 20 01 05 01 df 00
8 22 01 05 01 05 00
⑧ 22 01 05 01 df 00
9 24 01 05 01 05 00
⑨ 24 01 05 01 e2 00

となりますが,

レベル2では

①1 14 01 05 00
②2 16 01 05 00
③3 18 01 05 00
④4 1a 01 05 00
⑤5 1c 01 05 00
⑥6 1e 01 05 00
⑦7 20 01 05 00
⑧8 22 01 05 00
⑨9 24 01 05 00

となります。

テストページ:http://demo.icu-project.org/icu-bin/locexp?_=ja&d_=en&x=col&collation=search

Replace stringについていえば,

オプションの * を指定することにより,レベル5(文字コードで比較)のコレーションに切り替えることができます。(Position, Uppercase, Lowercaseも)

http://doc.4d.com/4Dv16/4D/16.3/Replace-string.301-3651270.ja.html

miyako

投稿数 : 483
登録日 : 2016/07/05

トップに戻る Go down

特殊数字とReplace String Empty Re: 特殊数字とReplace String

投稿 by osaru 2018-09-11, 5:22 pm

miyako様、いつも詳細にありがとうございます。
そういえばReplace stringの*オプションの話しは以前も聞いたような記憶がありますね。物覚えが悪くなりつつある今日この頃です(汗;

osaru

投稿数 : 67
登録日 : 2017/08/14

トップに戻る Go down

特殊数字とReplace String Empty Re: 特殊数字とReplace String

投稿 by Sponsored content


Sponsored content


トップに戻る Go down

トップに戻る

- Similar topics

 
Permissions in this forum:
返信投稿: 不可