ホーム › 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 | 選択された最適なロケールIDを格納する出力バッファ。 |
| resultAvailable | INT | in | result バッファの容量(バイト)。 |
| outResult | UAcceptResult* | inout | 一致種別を返すUAcceptResultポインタ。 |
| acceptList | CHAR** | in | 優先順に並んだ受理候補ロケール文字列の配列。 |
| acceptListCount | INT | in | acceptList の要素数。 |
| availableLocales | UEnumeration* | inout | 選択候補となる利用可能ロケールの列挙。 |
| status | UErrorCode* | inout | ICUエラーコードを受け渡すポインタ。U_ZERO_ERRORへ初期化が必要。 |
戻り値の型: 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, varptr(outResult), varptr(acceptList), acceptListCount, varptr(availableLocales), varptr(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, var, var, int, var, var ; res = uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status) ; result : LPSTR -> "str" ; resultAvailable : INT -> "int" ; outResult : UAcceptResult* in/out -> "var" ; acceptList : CHAR** -> "var" ; acceptListCount : INT -> "int" ; availableLocales : UEnumeration* in/out -> "var" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global uloc_acceptLanguage "uloc_acceptLanguage" str, int, sptr, sptr, int, sptr, sptr ; res = uloc_acceptLanguage(result, resultAvailable, varptr(outResult), varptr(acceptList), acceptListCount, varptr(availableLocales), varptr(status)) ; result : LPSTR -> "str" ; resultAvailable : INT -> "int" ; outResult : UAcceptResult* in/out -> "sptr" ; acceptList : CHAR** -> "sptr" ; acceptListCount : INT -> "int" ; availableLocales : UEnumeration* in/out -> "sptr" ; status : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(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, var, var, int, var, var ; res = uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status) ; result : LPSTR -> "str" ; resultAvailable : INT -> "int" ; outResult : UAcceptResult* in/out -> "var" ; acceptList : CHAR** -> "var" ; acceptListCount : INT -> "int" ; availableLocales : UEnumeration* in/out -> "var" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は 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, intptr, intptr, int, intptr, intptr ; res = uloc_acceptLanguage(result, resultAvailable, varptr(outResult), varptr(acceptList), acceptListCount, varptr(availableLocales), varptr(status)) ; result : LPSTR -> "str" ; resultAvailable : INT -> "int" ; outResult : UAcceptResult* in/out -> "intptr" ; acceptList : CHAR** -> "intptr" ; acceptListCount : INT -> "int" ; availableLocales : UEnumeration* in/out -> "intptr" ; status : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(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`,…) を使用。const std = @import("std");
extern "icuuc" fn uloc_acceptLanguage(
result: [*c]const u8, // LPSTR
resultAvailable: i32, // INT
outResult: [*c]i32, // UAcceptResult* in/out
acceptList: [*c][*c]i8, // CHAR**
acceptListCount: i32, // INT
availableLocales: [*c]isize, // UEnumeration* in/out
status: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc uloc_acceptLanguage(
result: cstring, # LPSTR
resultAvailable: int32, # INT
outResult: ptr int32, # UAcceptResult* in/out
acceptList: ptr int8, # CHAR**
acceptListCount: int32, # INT
availableLocales: ptr int, # UEnumeration* in/out
status: ptr int32 # UErrorCode* in/out
): int32 {.importc: "uloc_acceptLanguage", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
int uloc_acceptLanguage(
const(char)* result, // LPSTR
int resultAvailable, // INT
int* outResult, // UAcceptResult* in/out
byte** acceptList, // CHAR**
int acceptListCount, // INT
ptrdiff_t* availableLocales, // UEnumeration* in/out
int* status // UErrorCode* in/out
);ccall((:uloc_acceptLanguage, "icuuc.dll"), Int32,
(Cstring, Int32, Ptr{Int32}, Ptr{Int8}, Int32, Ptr{Int}, Ptr{Int32}),
result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status)
# result : LPSTR -> Cstring
# resultAvailable : INT -> Int32
# outResult : UAcceptResult* in/out -> Ptr{Int32}
# acceptList : CHAR** -> Ptr{Int8}
# acceptListCount : INT -> Int32
# availableLocales : UEnumeration* in/out -> Ptr{Int}
# status : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t uloc_acceptLanguage(
const char* result,
int32_t resultAvailable,
int32_t* outResult,
int8_t** acceptList,
int32_t acceptListCount,
intptr_t* availableLocales,
int32_t* status);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status)
-- result : LPSTR
-- resultAvailable : INT
-- outResult : UAcceptResult* in/out
-- acceptList : CHAR**
-- acceptListCount : INT
-- availableLocales : UEnumeration* in/out
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const uloc_acceptLanguage = lib.func('__cdecl', 'uloc_acceptLanguage', 'int32_t', ['str', 'int32_t', 'int32_t *', 'int8_t *', 'int32_t', 'intptr_t *', 'int32_t *']);
// uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status)
// result : LPSTR -> 'str'
// resultAvailable : INT -> 'int32_t'
// outResult : UAcceptResult* in/out -> 'int32_t *'
// acceptList : CHAR** -> 'int8_t *'
// acceptListCount : INT -> 'int32_t'
// availableLocales : UEnumeration* in/out -> 'intptr_t *'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
uloc_acceptLanguage: { parameters: ["buffer", "i32", "pointer", "pointer", "i32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status)
// result : LPSTR -> "buffer"
// resultAvailable : INT -> "i32"
// outResult : UAcceptResult* in/out -> "pointer"
// acceptList : CHAR** -> "pointer"
// acceptListCount : INT -> "i32"
// availableLocales : UEnumeration* in/out -> "pointer"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t uloc_acceptLanguage(
const char* result,
int32_t resultAvailable,
int32_t* outResult,
int8_t** acceptList,
int32_t acceptListCount,
intptr_t* availableLocales,
int32_t* status);
C, "icuuc.dll");
// $ffi->uloc_acceptLanguage(result, resultAvailable, outResult, acceptList, acceptListCount, availableLocales, status);
// result : LPSTR
// resultAvailable : INT
// outResult : UAcceptResult* in/out
// acceptList : CHAR**
// acceptListCount : INT
// availableLocales : UEnumeration* in/out
// status : UErrorCode* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Icuuc extends Library {
Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
int uloc_acceptLanguage(
String result, // LPSTR
int resultAvailable, // INT
IntByReference outResult, // UAcceptResult* in/out
Pointer acceptList, // CHAR**
int acceptListCount, // INT
LongByReference availableLocales, // UEnumeration* in/out
IntByReference status // UErrorCode* in/out
);
}@[Link("icuuc")]
lib Libicuuc
fun uloc_acceptLanguage = uloc_acceptLanguage(
result : UInt8*, # LPSTR
resultAvailable : Int32, # INT
outResult : Int32*, # UAcceptResult* in/out
acceptList : Int8**, # CHAR**
acceptListCount : Int32, # INT
availableLocales : LibC::SSizeT*, # UEnumeration* in/out
status : Int32* # UErrorCode* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef uloc_acceptLanguageNative = Int32 Function(Pointer<Utf8>, Int32, Pointer<Int32>, Pointer<Int8>, Int32, Pointer<IntPtr>, Pointer<Int32>);
typedef uloc_acceptLanguageDart = int Function(Pointer<Utf8>, int, Pointer<Int32>, Pointer<Int8>, int, Pointer<IntPtr>, Pointer<Int32>);
final uloc_acceptLanguage = DynamicLibrary.open('icuuc.dll')
.lookupFunction<uloc_acceptLanguageNative, uloc_acceptLanguageDart>('uloc_acceptLanguage');
// result : LPSTR -> Pointer<Utf8>
// resultAvailable : INT -> Int32
// outResult : UAcceptResult* in/out -> Pointer<Int32>
// acceptList : CHAR** -> Pointer<Int8>
// acceptListCount : INT -> Int32
// availableLocales : UEnumeration* in/out -> Pointer<IntPtr>
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function 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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "uloc_acceptLanguage"
c_uloc_acceptLanguage :: CString -> Int32 -> Ptr Int32 -> Ptr Int8 -> Int32 -> Ptr CIntPtr -> Ptr Int32 -> IO Int32
-- result : LPSTR -> CString
-- resultAvailable : INT -> Int32
-- outResult : UAcceptResult* in/out -> Ptr Int32
-- acceptList : CHAR** -> Ptr Int8
-- acceptListCount : INT -> Int32
-- availableLocales : UEnumeration* in/out -> Ptr CIntPtr
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let uloc_acceptlanguage =
foreign "uloc_acceptLanguage"
(string @-> int32_t @-> (ptr int32_t) @-> (ptr int8_t) @-> int32_t @-> (ptr intptr_t) @-> (ptr int32_t) @-> returning int32_t)
(* result : LPSTR -> string *)
(* resultAvailable : INT -> int32_t *)
(* outResult : UAcceptResult* in/out -> (ptr int32_t) *)
(* acceptList : CHAR** -> (ptr int8_t) *)
(* acceptListCount : INT -> int32_t *)
(* availableLocales : UEnumeration* in/out -> (ptr intptr_t) *)
(* status : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("uloc_acceptLanguage" uloc-accept-language :convention :cdecl) :int32
(result :string) ; LPSTR
(result-available :int32) ; INT
(out-result :pointer) ; UAcceptResult* in/out
(accept-list :pointer) ; CHAR**
(accept-list-count :int32) ; INT
(available-locales :pointer) ; UEnumeration* in/out
(status :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $uloc_acceptLanguage = Win32::API::More->new('icuuc',
'int uloc_acceptLanguage(LPCSTR result, int resultAvailable, LPVOID outResult, LPVOID acceptList, int acceptListCount, LPVOID availableLocales, LPVOID status)');
# my $ret = $uloc_acceptLanguage->Call($result, $resultAvailable, $outResult, $acceptList, $acceptListCount, $availableLocales, $status);
# result : LPSTR -> LPCSTR
# resultAvailable : INT -> int
# outResult : UAcceptResult* in/out -> LPVOID
# acceptList : CHAR** -> LPVOID
# acceptListCount : INT -> int
# availableLocales : UEnumeration* in/out -> LPVOID
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。