Win32 API 日本語リファレンス
ホームGlobalization › u_catopen

u_catopen

関数
メッセージカタログをロケール指定で開く。
DLLicuuc.dll呼出規約cdecl

シグネチャ

// icuuc.dll
#include <windows.h>

UResourceBundle* u_catopen(
    LPCSTR name,
    LPCSTR locale,
    UErrorCode* ec
);

パラメーター

名前方向説明
nameLPCSTRin開くメッセージカタログ(データパッケージ)の名前(NUL終端)。
localeLPCSTRinカタログのロケール(NUL終端)。NULLで既定ロケール。
ecUErrorCode*inoutエラーコードを入出力するポインタ。事前にU_ZERO_ERRORで初期化する。

戻り値の型: UResourceBundle*

各言語での呼び出し定義

// icuuc.dll
#include <windows.h>

UResourceBundle* u_catopen(
    LPCSTR name,
    LPCSTR locale,
    UErrorCode* ec
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr u_catopen(
    [MarshalAs(UnmanagedType.LPStr)] string name,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string locale,   // LPCSTR
    ref int ec   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_catopen(
    <MarshalAs(UnmanagedType.LPStr)> name As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> locale As String,   ' LPCSTR
    ByRef ec As Integer   ' UErrorCode* in/out
) As IntPtr
End Function
' name : LPCSTR
' locale : LPCSTR
' ec : UErrorCode* in/out
Declare PtrSafe Function u_catopen Lib "icuuc" ( _
    ByVal name As String, _
    ByVal locale As String, _
    ByRef ec As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

u_catopen = ctypes.cdll.icuuc.u_catopen
u_catopen.restype = ctypes.c_void_p
u_catopen.argtypes = [
    wintypes.LPCSTR,  # name : LPCSTR
    wintypes.LPCSTR,  # locale : LPCSTR
    ctypes.c_void_p,  # ec : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
u_catopen = Fiddle::Function.new(
  lib['u_catopen'],
  [
    Fiddle::TYPE_VOIDP,  # name : LPCSTR
    Fiddle::TYPE_VOIDP,  # locale : LPCSTR
    Fiddle::TYPE_VOIDP,  # ec : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn u_catopen(
        name: *const u8,  // LPCSTR
        locale: *const u8,  // LPCSTR
        ec: *mut i32  // UErrorCode* in/out
    ) -> *mut isize;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr u_catopen([MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string locale, ref int ec);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_catopen' -Namespace Win32 -PassThru
# $api::u_catopen(name, locale, ec)
#uselib "icuuc.dll"
#func global u_catopen "u_catopen" sptr, sptr, sptr
; u_catopen name, locale, varptr(ec)   ; 戻り値は stat
; name : LPCSTR -> "sptr"
; locale : LPCSTR -> "sptr"
; ec : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global u_catopen "u_catopen" str, str, var
; res = u_catopen(name, locale, ec)
; name : LPCSTR -> "str"
; locale : LPCSTR -> "str"
; ec : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; UResourceBundle* u_catopen(LPCSTR name, LPCSTR locale, UErrorCode* ec)
#uselib "icuuc.dll"
#cfunc global u_catopen "u_catopen" str, str, var
; res = u_catopen(name, locale, ec)
; name : LPCSTR -> "str"
; locale : LPCSTR -> "str"
; ec : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_catopen = icuuc.NewProc("u_catopen")
)

// name (LPCSTR), locale (LPCSTR), ec (UErrorCode* in/out)
r1, _, err := procu_catopen.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(name))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
	uintptr(ec),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // UResourceBundle*
function u_catopen(
  name: PAnsiChar;   // LPCSTR
  locale: PAnsiChar;   // LPCSTR
  ec: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuuc.dll' name 'u_catopen';
result := DllCall("icuuc\u_catopen"
    , "AStr", name   ; LPCSTR
    , "AStr", locale   ; LPCSTR
    , "Ptr", ec   ; UErrorCode* in/out
    , "Cdecl Ptr")   ; return: UResourceBundle*
●u_catopen(name, locale, ec) = DLL("icuuc.dll", "void* u_catopen(char*, char*, void*)")
# 呼び出し: u_catopen(name, locale, ec)
# name : LPCSTR -> "char*"
# locale : LPCSTR -> "char*"
# ec : 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 u_catopen(
    name: [*c]const u8, // LPCSTR
    locale: [*c]const u8, // LPCSTR
    ec: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]isize;
proc u_catopen(
    name: cstring,  # LPCSTR
    locale: cstring,  # LPCSTR
    ec: ptr int32  # UErrorCode* in/out
): ptr int {.importc: "u_catopen", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
ptrdiff_t* u_catopen(
    const(char)* name,   // LPCSTR
    const(char)* locale,   // LPCSTR
    int* ec   // UErrorCode* in/out
);
ccall((:u_catopen, "icuuc.dll"), Ptr{Int},
      (Cstring, Cstring, Ptr{Int32}),
      name, locale, ec)
# name : LPCSTR -> Cstring
# locale : LPCSTR -> Cstring
# ec : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
intptr_t* u_catopen(
    const char* name,
    const char* locale,
    int32_t* ec);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.u_catopen(name, locale, ec)
-- name : LPCSTR
-- locale : LPCSTR
-- ec : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const u_catopen = lib.func('__cdecl', 'u_catopen', 'intptr_t *', ['str', 'str', 'int32_t *']);
// u_catopen(name, locale, ec)
// name : LPCSTR -> 'str'
// locale : LPCSTR -> 'str'
// ec : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  u_catopen: { parameters: ["buffer", "buffer", "pointer"], result: "pointer" },
});
// lib.symbols.u_catopen(name, locale, ec)
// name : LPCSTR -> "buffer"
// locale : LPCSTR -> "buffer"
// ec : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
intptr_t* u_catopen(
    const char* name,
    const char* locale,
    int32_t* ec);
C, "icuuc.dll");
// $ffi->u_catopen(name, locale, ec);
// name : LPCSTR
// locale : LPCSTR
// ec : 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);
    Pointer u_catopen(
        String name,   // LPCSTR
        String locale,   // LPCSTR
        IntByReference ec   // UErrorCode* in/out
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun u_catopen = u_catopen(
    name : UInt8*,   # LPCSTR
    locale : UInt8*,   # LPCSTR
    ec : Int32*   # UErrorCode* in/out
  ) : LibC::SSizeT*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef u_catopenNative = Pointer<IntPtr> Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Int32>);
typedef u_catopenDart = Pointer<IntPtr> Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Int32>);
final u_catopen = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<u_catopenNative, u_catopenDart>('u_catopen');
// name : LPCSTR -> Pointer<Utf8>
// locale : LPCSTR -> Pointer<Utf8>
// ec : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function u_catopen(
  name: PAnsiChar;   // LPCSTR
  locale: PAnsiChar;   // LPCSTR
  ec: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuuc.dll' name 'u_catopen';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "u_catopen"
  c_u_catopen :: CString -> CString -> Ptr Int32 -> IO (Ptr CIntPtr)
-- name : LPCSTR -> CString
-- locale : LPCSTR -> CString
-- ec : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let u_catopen =
  foreign "u_catopen"
    (string @-> string @-> (ptr int32_t) @-> returning (ptr intptr_t))
(* name : LPCSTR -> string *)
(* locale : LPCSTR -> string *)
(* ec : 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 ("u_catopen" u-catopen :convention :cdecl) :pointer
  (name :string)   ; LPCSTR
  (locale :string)   ; LPCSTR
  (ec :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $u_catopen = Win32::API::More->new('icuuc',
    'LPVOID u_catopen(LPCSTR name, LPCSTR locale, LPVOID ec)');
# my $ret = $u_catopen->Call($name, $locale, $ec);
# name : LPCSTR -> LPCSTR
# locale : LPCSTR -> LPCSTR
# ec : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型