ホーム › Globalization › uloc_getScript
uloc_getScript
関数ロケールIDからスクリプトコードを取り出す。
シグネチャ
// icuuc.dll
#include <windows.h>
INT uloc_getScript(
LPCSTR localeID,
LPSTR script,
INT scriptCapacity,
UErrorCode* err
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| localeID | LPCSTR | in |
| script | LPSTR | in |
| scriptCapacity | INT | in |
| err | UErrorCode* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT uloc_getScript(
LPCSTR localeID,
LPSTR script,
INT scriptCapacity,
UErrorCode* err
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uloc_getScript(
[MarshalAs(UnmanagedType.LPStr)] string localeID, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string script, // LPSTR
int scriptCapacity, // INT
ref int err // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uloc_getScript(
<MarshalAs(UnmanagedType.LPStr)> localeID As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> script As String, ' LPSTR
scriptCapacity As Integer, ' INT
ByRef err As Integer ' UErrorCode* in/out
) As Integer
End Function' localeID : LPCSTR
' script : LPSTR
' scriptCapacity : INT
' err : UErrorCode* in/out
Declare PtrSafe Function uloc_getScript Lib "icuuc" ( _
ByVal localeID As String, _
ByVal script As String, _
ByVal scriptCapacity As Long, _
ByRef err As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
uloc_getScript = ctypes.cdll.icuuc.uloc_getScript
uloc_getScript.restype = ctypes.c_int
uloc_getScript.argtypes = [
wintypes.LPCSTR, # localeID : LPCSTR
wintypes.LPCSTR, # script : LPSTR
ctypes.c_int, # scriptCapacity : INT
ctypes.c_void_p, # err : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
uloc_getScript = Fiddle::Function.new(
lib['uloc_getScript'],
[
Fiddle::TYPE_VOIDP, # localeID : LPCSTR
Fiddle::TYPE_VOIDP, # script : LPSTR
Fiddle::TYPE_INT, # scriptCapacity : INT
Fiddle::TYPE_VOIDP, # err : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn uloc_getScript(
localeID: *const u8, // LPCSTR
script: *mut u8, // LPSTR
scriptCapacity: i32, // INT
err: *mut i32 // UErrorCode* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int uloc_getScript([MarshalAs(UnmanagedType.LPStr)] string localeID, [MarshalAs(UnmanagedType.LPStr)] string script, int scriptCapacity, ref int err);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uloc_getScript' -Namespace Win32 -PassThru
# $api::uloc_getScript(localeID, script, scriptCapacity, err)#uselib "icuuc.dll"
#func global uloc_getScript "uloc_getScript" sptr, sptr, sptr, sptr
; uloc_getScript localeID, script, scriptCapacity, err ; 戻り値は stat
; localeID : LPCSTR -> "sptr"
; script : LPSTR -> "sptr"
; scriptCapacity : INT -> "sptr"
; err : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "icuuc.dll"
#cfunc global uloc_getScript "uloc_getScript" str, str, int, int
; res = uloc_getScript(localeID, script, scriptCapacity, err)
; localeID : LPCSTR -> "str"
; script : LPSTR -> "str"
; scriptCapacity : INT -> "int"
; err : UErrorCode* in/out -> "int"; INT uloc_getScript(LPCSTR localeID, LPSTR script, INT scriptCapacity, UErrorCode* err)
#uselib "icuuc.dll"
#cfunc global uloc_getScript "uloc_getScript" str, str, int, int
; res = uloc_getScript(localeID, script, scriptCapacity, err)
; localeID : LPCSTR -> "str"
; script : LPSTR -> "str"
; scriptCapacity : INT -> "int"
; err : UErrorCode* in/out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
proculoc_getScript = icuuc.NewProc("uloc_getScript")
)
// localeID (LPCSTR), script (LPSTR), scriptCapacity (INT), err (UErrorCode* in/out)
r1, _, err := proculoc_getScript.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(localeID))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(script))),
uintptr(scriptCapacity),
uintptr(err),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction uloc_getScript(
localeID: PAnsiChar; // LPCSTR
script: PAnsiChar; // LPSTR
scriptCapacity: Integer; // INT
err: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'uloc_getScript';result := DllCall("icuuc\uloc_getScript"
, "AStr", localeID ; LPCSTR
, "AStr", script ; LPSTR
, "Int", scriptCapacity ; INT
, "Ptr", err ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●uloc_getScript(localeID, script, scriptCapacity, err) = DLL("icuuc.dll", "int uloc_getScript(char*, char*, int, void*)")
# 呼び出し: uloc_getScript(localeID, script, scriptCapacity, err)
# localeID : LPCSTR -> "char*"
# script : LPSTR -> "char*"
# scriptCapacity : INT -> "int"
# err : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。