How to check string by hexa code

1.Unicodeの外字範囲をチェックする。                       
 ・ BMP領域 U+E000‐U+F8FF (6,400字)                     
 ・ 15面 U+F0000‐U+FFFFD (65,534字)                     
 ・ 16面 U+100000‐U+10FFFD (65,534字)                     
                       
 1-1.外字が含まれている場合                     
  ・ 外字を文字列「_(半角)」に置換する                   
  ・ 以下のメッセージを出力する                   
   ・ エラーレベル:INFOで出力する                   
   ・ メッセージの引数に機能ID、項目名を設定し、ログに出力する                   
   ・ メッセージID:W-Z1010‐2003
==============================================================
1. Check the external character range of Unicode.
· BMP area U + E000 - U + F 8 FF (6,400 characters)
· 15 faces U + F 0000 - U + FFFFD (65,534 characters)
· 16 sides U + 100000 - U + 10 FFFD (65,534 characters)

1-1. When external characters are included
· Replace the external character with the character string "_ (half size)"
· Output the following message
· Error level: Output with INFO
· Set the function ID and item name as the argument of the message and output it to the log
Message ID: W - Z 1010 - 2003
==============================================================

// Check external chacracter
  checkExternalChacracter() {
    const regex = /[\ue000-\uf8fe]|[\udb80-\udbbe\udbc0-\udbfe][\udc00-\udfff]|\udbbf[\udc00-\udffe]|\udbff[\udc00-\udffe]/;
    const form = this.registerForm;

    const array_construct_external = this.registerForm.get('content_code').value.match((new RegExp(regex, 'g')));
    if (array_construct_external) {
      console.log(array_construct_external);
      for (const item_c of array_construct_external) {
        console.log(item_c);
        form.patchValue({content_code: this.registerForm.get('content_code').value.replace(new RegExp(item_c, 'g'), '_')});
      }
      this._Log.Info(`B1050 - ${DEF.C_W_Z1010_2003.replace('{str1}', 'checkExternalChacracter').replace('{str2}', '工事内容')}`);
    }

    const array_remark_external = this.registerForm.get('frm_remark').value.match((new RegExp(regex, 'g')));
    if (array_remark_external) {
      for (const item_r of array_remark_external) {
        form.patchValue({frm_remark: this.registerForm.get('frm_remark').value.replace(new RegExp(item_r, 'g'), '_')});
      }
      this._Log.Info(`B1050 - ${DEF.C_W_Z1010_2003.replace('{str1}', 'checkExternalChacracter').replace('{str2}', '備考')}`);
    }
  }

Comments

Popular Posts