ホーム › UI.WindowsAndMessaging › IsCharAlphaNumericA
IsCharAlphaNumericA
関数文字が英数字かを判定する(ANSI)。
シグネチャ
// USER32.dll (ANSI / -A)
#include <windows.h>
BOOL IsCharAlphaNumericA(
CHAR ch
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ch | CHAR | in | テストする文字。 |
戻り値の型: BOOL
公式ドキュメント
文字が英字または数字のいずれかであるかどうかを判定します。この判定は、セットアップ時またはコントロールパネルでユーザーが選択した言語のセマンティクスに基づきます。(ANSI)
戻り値
解説(Remarks)
メモ
winuser.h ヘッダーは IsCharAlphaNumeric をエイリアスとして定義しており、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択します。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、コンパイルエラーや実行時エラーを引き起こす不整合が生じる可能性があります。詳細については、関数プロトタイプの規約を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USER32.dll (ANSI / -A)
#include <windows.h>
BOOL IsCharAlphaNumericA(
CHAR ch
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool IsCharAlphaNumericA(
sbyte ch // CHAR
);<DllImport("USER32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function IsCharAlphaNumericA(
ch As SByte ' CHAR
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' ch : CHAR
Declare PtrSafe Function IsCharAlphaNumericA Lib "user32" ( _
ByVal ch As Byte) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IsCharAlphaNumericA = ctypes.windll.user32.IsCharAlphaNumericA
IsCharAlphaNumericA.restype = wintypes.BOOL
IsCharAlphaNumericA.argtypes = [
ctypes.c_byte, # ch : CHAR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
IsCharAlphaNumericA = Fiddle::Function.new(
lib['IsCharAlphaNumericA'],
[
Fiddle::TYPE_CHAR, # ch : CHAR
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn IsCharAlphaNumericA(
ch: i8 // CHAR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool IsCharAlphaNumericA(sbyte ch);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_IsCharAlphaNumericA' -Namespace Win32 -PassThru
# $api::IsCharAlphaNumericA(ch)#uselib "USER32.dll"
#func global IsCharAlphaNumericA "IsCharAlphaNumericA" sptr
; IsCharAlphaNumericA ch ; 戻り値は stat
; ch : CHAR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global IsCharAlphaNumericA "IsCharAlphaNumericA" int
; res = IsCharAlphaNumericA(ch)
; ch : CHAR -> "int"; BOOL IsCharAlphaNumericA(CHAR ch)
#uselib "USER32.dll"
#cfunc global IsCharAlphaNumericA "IsCharAlphaNumericA" int
; res = IsCharAlphaNumericA(ch)
; ch : CHAR -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procIsCharAlphaNumericA = user32.NewProc("IsCharAlphaNumericA")
)
// ch (CHAR)
r1, _, err := procIsCharAlphaNumericA.Call(
uintptr(ch),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction IsCharAlphaNumericA(
ch: Shortint // CHAR
): BOOL; stdcall;
external 'USER32.dll' name 'IsCharAlphaNumericA';result := DllCall("USER32\IsCharAlphaNumericA"
, "Char", ch ; CHAR
, "Int") ; return: BOOL●IsCharAlphaNumericA(ch) = DLL("USER32.dll", "bool IsCharAlphaNumericA(char)")
# 呼び出し: IsCharAlphaNumericA(ch)
# ch : CHAR -> "char"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "user32" fn IsCharAlphaNumericA(
ch: i8 // CHAR
) callconv(std.os.windows.WINAPI) i32;proc IsCharAlphaNumericA(
ch: int8 # CHAR
): int32 {.importc: "IsCharAlphaNumericA", stdcall, dynlib: "USER32.dll".}pragma(lib, "user32");
extern(Windows)
int IsCharAlphaNumericA(
byte ch // CHAR
);ccall((:IsCharAlphaNumericA, "USER32.dll"), stdcall, Int32,
(Int8,),
ch)
# ch : CHAR -> Int8
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t IsCharAlphaNumericA(
int8_t ch);
]]
local user32 = ffi.load("user32")
-- user32.IsCharAlphaNumericA(ch)
-- ch : CHAR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const IsCharAlphaNumericA = lib.func('__stdcall', 'IsCharAlphaNumericA', 'int32_t', ['int8_t']);
// IsCharAlphaNumericA(ch)
// ch : CHAR -> 'int8_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USER32.dll", {
IsCharAlphaNumericA: { parameters: ["i8"], result: "i32" },
});
// lib.symbols.IsCharAlphaNumericA(ch)
// ch : CHAR -> "i8"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t IsCharAlphaNumericA(
int8_t ch);
C, "USER32.dll");
// $ffi->IsCharAlphaNumericA(ch);
// ch : CHAR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface User32 extends StdCallLibrary {
User32 INSTANCE = Native.load("user32", User32.class, W32APIOptions.ASCII_OPTIONS);
boolean IsCharAlphaNumericA(
byte ch // CHAR
);
}@[Link("user32")]
lib LibUSER32
fun IsCharAlphaNumericA = IsCharAlphaNumericA(
ch : Int8 # CHAR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef IsCharAlphaNumericANative = Int32 Function(Int8);
typedef IsCharAlphaNumericADart = int Function(int);
final IsCharAlphaNumericA = DynamicLibrary.open('USER32.dll')
.lookupFunction<IsCharAlphaNumericANative, IsCharAlphaNumericADart>('IsCharAlphaNumericA');
// ch : CHAR -> Int8
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function IsCharAlphaNumericA(
ch: Shortint // CHAR
): BOOL; stdcall;
external 'USER32.dll' name 'IsCharAlphaNumericA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "IsCharAlphaNumericA"
c_IsCharAlphaNumericA :: Int8 -> IO CInt
-- ch : CHAR -> Int8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ischaralphanumerica =
foreign "IsCharAlphaNumericA"
(int8_t @-> returning int32_t)
(* ch : CHAR -> int8_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)
(cffi:defcfun ("IsCharAlphaNumericA" is-char-alpha-numeric-a :convention :stdcall) :int32
(ch :int8)) ; CHAR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $IsCharAlphaNumericA = Win32::API::More->new('USER32',
'BOOL IsCharAlphaNumericA(char ch)');
# my $ret = $IsCharAlphaNumericA->Call($ch);
# ch : CHAR -> char
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f IsCharAlphaNumericW (Unicode版) — 文字が英数字かを判定する(Unicode)。
公式の関連項目
- f IsCharAlphaA — 文字が英字かを判定する(ANSI)。