LoginSignup
0
0

More than 3 years have passed since last update.

VBSでJIS第3水準以上の漢字を判定する

Posted at

はじめに

あるシステムに山﨑様と入力したら、JIS第3水準以上の漢字が化けてしまい、クレームになったことが…そこで、事前にJIS第3水準以上の漢字を判定するスクリプトを書いてみました。

スクリプト

test.vbs
Option Explicit

'宣言
Dim str
Dim str_count
Dim i
Dim flg
Dim tmp
Dim char
Dim char_code

'代入
str = WScript.arguments(0)
str_count = Len(str)
flg = False

'処理
For i = 1 To str_count
    char = Mid(str, i, 1)
    char_code = Asc(char)
    If char_code > &HEAA5 And char_code < &H0 Then
        flg = True
        WScript.echo char
    End If
Next

'出力
If flg Then
    WScript.echo "がJIS第3水準以上の漢字です。"
Else
    WScript.echo "JIS第3水準以上の漢字は含まれていませんでした。"
End If

使い方

cmd
C:\>cscript test.vbs Qiitaは便利♪
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

JIS第3水準以上の漢字は含まれていませんでした。

C:\>cscript test.vbs 山﨑髙橋
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

﨑
髙
がJIS第3水準以上の漢字です。

C:\>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0