ホーム › Globalization › uloc_acceptLanguage
uloc_acceptLanguage
関数受理言語リストから利用可能な最適ロケールを選択する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT uloc_acceptLanguage(
LPSTR result,
INT resultAvailable,
UAcceptResult* outResult,
const CHAR** acceptList,
INT acceptListCount,
UEnumeration* availableLocales,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| result | LPSTR | in |
| resultAvailable | INT | in |
| outResult | UAcceptResult* | inout |
| acceptList | CHAR** | in |
| acceptListCount | INT | in |
| availableLocales | UEnumeration* | inout |
| status | UErrorCode* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT uloc_acceptLanguage(
LPSTR result,
INT resultAvailable,
UAcceptResult* outResult,
const CHAR** acceptList,
INT acceptListCount,
UEnumeration* availableLocales,
UErrorCode* status
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uloc_acceptLanguage(
[MarshalAs(UnmanagedType.LPStr)] string result, // LPSTR
int resultAvailable, // INT
ref int outResult, // UAcceptResult* in/out
IntPtr acceptList, // CHAR**
int acceptListCount, // INT
ref IntPtr availableLocales, // UEnumeration* in/out
ref int status // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uloc_acceptLanguage(
<MarshalAs(UnmanagedType.LPStr)> result As String, ' LPSTR
resultAvailable As Integer, ' INT
ByRef outResult As Integer, ' UAcceptResult* in/out
acceptList As IntPtr, ' CHAR**
acceptListCount As Integer, ' INT
ByRef availableLocales As IntPtr, ' UEnumeration* in/out
ByRef status As Integer ' UErrorCode* in/out
) As Integer
End Function' result : LPSTR
' resultAvailable : INT
' outResult : UAcceptResult* in/out
' acceptList : CHAR**
' acceptListCount : INT
' availableLocales : UEnumeration* in/out
' status : UErrorCode* in/out
Declare PtrSafe Function uloc_acceptLanguage Lib "icuuc" ( _
ByVal result As String, _
ByVal resultAvailable As Long, _
ByRef outResult As Long, _
ByVal acceptList As LongPtr, _
ByVal acceptListCount As Long, _
ByRef availableLocales As LongPtr, _
ByRef status As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
uloc_acceptLanguage = ctypes.cdll.icuuc.uloc_acceptLanguage
uloc_acceptLanguage.restype = ctypes.c_int
uloc_acceptLanguage.argtypes = [
wintypes.LPCSTR, # result : LPSTR
ctypes.c_int, # resultAvailable : INT
ctypes.c_void_p, # outResult : UAcceptResult* in/out
ctypes.c_void_p, # acceptList : CHAR**
ctypes.c_int, # acceptListCount : INT
ctypes.c_void_p, # availableLocales : UEnumeration* in/out
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
uloc_acceptLanguage = Fiddle::Function.new(
lib['uloc_acceptLanguage'],
[
Fiddle::TYPE_VOIDP, # result : LPSTR
Fiddle::TYPE_INT, # resultAvailable : INT
Fiddle::TYPE_VOIDP, # outResult : UAcceptResult* in/out
Fiddle::TYPE_VOIDP, # acceptList : CHAR**
Fiddle::TYPE_INT, # acceptListCount : INT
Fiddle::TYPE_VOIDP, # availableLocales : UEnumeration* in/out
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn uloc_acceptLanguage(
result: *mut u8, // LPSTR
resultAvailable: i32, // INT
outResult: *mut i32, // UAcceptResult* in/out
acceptList: *const *const i8, // CHAR**
acceptListCount: i32, // INT
availableLocales: *mut isize, // UEnumeration* in/out
status: *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_acceptLanguage([MarshalAs(UnmanagedType.LPStr)] string result, int resultAvailable, ref int outResult, IntPtr acceptList, int acceptListCount, ref IntPtr availableLocales, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uloc_acceptLanguage' -Namespace Win32 -PassThru
# $api::uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status)#uselib "icuuc.dll"
#func global uloc_acceptLanguage "uloc_acceptLanguage" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; uloc_acceptLanguage result, resultAvailable, outResult, varptr(acceptList), acceptListCount, availableLocales, status ; 戻り値は stat
; result : LPSTR -> "sptr"
; resultAvailable : INT -> "sptr"
; outResult : UAcceptResult* in/out -> "sptr"
; acceptList : CHAR** -> "sptr"
; acceptListCount : INT -> "sptr"
; availableLocales : UEnumeration* in/out -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global uloc_acceptLanguage "uloc_acceptLanguage" str, int, int, var, int, int, int ; res = uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status) ; result : LPSTR -> "str" ; resultAvailable : INT -> "int" ; outResult : UAcceptResult* in/out -> "int" ; acceptList : CHAR** -> "var" ; acceptListCount : INT -> "int" ; availableLocales : UEnumeration* in/out -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global uloc_acceptLanguage "uloc_acceptLanguage" str, int, int, sptr, int, int, int ; res = uloc_acceptLanguage(result, resultAvailable, outResult, varptr(acceptList), acceptListCount, availableLocales, status) ; result : LPSTR -> "str" ; resultAvailable : INT -> "int" ; outResult : UAcceptResult* in/out -> "int" ; acceptList : CHAR** -> "sptr" ; acceptListCount : INT -> "int" ; availableLocales : UEnumeration* in/out -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT uloc_acceptLanguage(LPSTR result, INT resultAvailable, UAcceptResult* outResult, CHAR** acceptList, INT acceptListCount, UEnumeration* availableLocales, UErrorCode* status) #uselib "icuuc.dll" #cfunc global uloc_acceptLanguage "uloc_acceptLanguage" str, int, int, var, int, int, int ; res = uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status) ; result : LPSTR -> "str" ; resultAvailable : INT -> "int" ; outResult : UAcceptResult* in/out -> "int" ; acceptList : CHAR** -> "var" ; acceptListCount : INT -> "int" ; availableLocales : UEnumeration* in/out -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT uloc_acceptLanguage(LPSTR result, INT resultAvailable, UAcceptResult* outResult, CHAR** acceptList, INT acceptListCount, UEnumeration* availableLocales, UErrorCode* status) #uselib "icuuc.dll" #cfunc global uloc_acceptLanguage "uloc_acceptLanguage" str, int, int, intptr, int, int, int ; res = uloc_acceptLanguage(result, resultAvailable, outResult, varptr(acceptList), acceptListCount, availableLocales, status) ; result : LPSTR -> "str" ; resultAvailable : INT -> "int" ; outResult : UAcceptResult* in/out -> "int" ; acceptList : CHAR** -> "intptr" ; acceptListCount : INT -> "int" ; availableLocales : UEnumeration* in/out -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
proculoc_acceptLanguage = icuuc.NewProc("uloc_acceptLanguage")
)
// result (LPSTR), resultAvailable (INT), outResult (UAcceptResult* in/out), acceptList (CHAR**), acceptListCount (INT), availableLocales (UEnumeration* in/out), status (UErrorCode* in/out)
r1, _, err := proculoc_acceptLanguage.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(result))),
uintptr(resultAvailable),
uintptr(outResult),
uintptr(acceptList),
uintptr(acceptListCount),
uintptr(availableLocales),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction uloc_acceptLanguage(
result: PAnsiChar; // LPSTR
resultAvailable: Integer; // INT
outResult: Pointer; // UAcceptResult* in/out
acceptList: Pointer; // CHAR**
acceptListCount: Integer; // INT
availableLocales: Pointer; // UEnumeration* in/out
status: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'uloc_acceptLanguage';result := DllCall("icuuc\uloc_acceptLanguage"
, "AStr", result ; LPSTR
, "Int", resultAvailable ; INT
, "Ptr", outResult ; UAcceptResult* in/out
, "Ptr", acceptList ; CHAR**
, "Int", acceptListCount ; INT
, "Ptr", availableLocales ; UEnumeration* in/out
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status) = DLL("icuuc.dll", "int uloc_acceptLanguage(char*, int, void*, void*, int, void*, void*)")
# 呼び出し: uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status)
# result : LPSTR -> "char*"
# resultAvailable : INT -> "int"
# outResult : UAcceptResult* in/out -> "void*"
# acceptList : CHAR** -> "void*"
# acceptListCount : INT -> "int"
# availableLocales : UEnumeration* in/out -> "void*"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。