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