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

ubrk_open

関数
種別とロケールを指定してテキスト分割イテレータを開く。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

UBreakIterator* ubrk_open(
    UBreakIteratorType type,
    LPCSTR locale,
    const WORD* text,
    INT textLength,
    UErrorCode* status
);

パラメーター

名前方向
typeUBreakIteratorTypein
localeLPCSTRin
textWORD*in
textLengthINTin
statusUErrorCode*inout

戻り値の型: UBreakIterator*

各言語での呼び出し定義

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

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

ubrk_open = ctypes.cdll.icuuc.ubrk_open
ubrk_open.restype = ctypes.c_void_p
ubrk_open.argtypes = [
    ctypes.c_int,  # type : UBreakIteratorType
    wintypes.LPCSTR,  # locale : LPCSTR
    ctypes.POINTER(ctypes.c_ushort),  # text : WORD*
    ctypes.c_int,  # textLength : INT
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
ubrk_open = Fiddle::Function.new(
  lib['ubrk_open'],
  [
    Fiddle::TYPE_INT,  # type : UBreakIteratorType
    Fiddle::TYPE_VOIDP,  # locale : LPCSTR
    Fiddle::TYPE_VOIDP,  # text : WORD*
    Fiddle::TYPE_INT,  # textLength : INT
    Fiddle::TYPE_VOIDP,  # status : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn ubrk_open(
        type: i32,  // UBreakIteratorType
        locale: *const u8,  // LPCSTR
        text: *const u16,  // WORD*
        textLength: i32,  // INT
        status: *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 ubrk_open(int type, [MarshalAs(UnmanagedType.LPStr)] string locale, ref ushort text, int textLength, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ubrk_open' -Namespace Win32 -PassThru
# $api::ubrk_open(type, locale, text, textLength, status)
#uselib "icuuc.dll"
#func global ubrk_open "ubrk_open" sptr, sptr, sptr, sptr, sptr
; ubrk_open type, locale, varptr(text), textLength, status   ; 戻り値は stat
; type : UBreakIteratorType -> "sptr"
; locale : LPCSTR -> "sptr"
; text : WORD* -> "sptr"
; textLength : INT -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global ubrk_open "ubrk_open" int, str, var, int, int
; res = ubrk_open(type, locale, text, textLength, status)
; type : UBreakIteratorType -> "int"
; locale : LPCSTR -> "str"
; text : WORD* -> "var"
; textLength : INT -> "int"
; status : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; UBreakIterator* ubrk_open(UBreakIteratorType type, LPCSTR locale, WORD* text, INT textLength, UErrorCode* status)
#uselib "icuuc.dll"
#cfunc global ubrk_open "ubrk_open" int, str, var, int, int
; res = ubrk_open(type, locale, text, textLength, status)
; type : UBreakIteratorType -> "int"
; locale : LPCSTR -> "str"
; text : WORD* -> "var"
; textLength : INT -> "int"
; status : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procubrk_open = icuuc.NewProc("ubrk_open")
)

// type (UBreakIteratorType), locale (LPCSTR), text (WORD*), textLength (INT), status (UErrorCode* in/out)
r1, _, err := procubrk_open.Call(
	uintptr(type),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
	uintptr(text),
	uintptr(textLength),
	uintptr(status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // UBreakIterator*
function ubrk_open(
  type: Integer;   // UBreakIteratorType
  locale: PAnsiChar;   // LPCSTR
  text: Pointer;   // WORD*
  textLength: Integer;   // INT
  status: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuuc.dll' name 'ubrk_open';
result := DllCall("icuuc\ubrk_open"
    , "Int", type   ; UBreakIteratorType
    , "AStr", locale   ; LPCSTR
    , "Ptr", text   ; WORD*
    , "Int", textLength   ; INT
    , "Ptr", status   ; UErrorCode* in/out
    , "Cdecl Ptr")   ; return: UBreakIterator*
●ubrk_open(type, locale, text, textLength, status) = DLL("icuuc.dll", "void* ubrk_open(int, char*, void*, int, void*)")
# 呼び出し: ubrk_open(type, locale, text, textLength, status)
# type : UBreakIteratorType -> "int"
# locale : LPCSTR -> "char*"
# text : WORD* -> "void*"
# textLength : INT -> "int"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。