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生成する区切り反復子の種別を示すUBreakIteratorType列挙値。
localeLPCSTRin境界規則に用いるロケールID。NULLで既定ロケール。
textWORD*in走査対象のUTF-16テキストを指す。後でsetText可。NULL可。
textLengthINTintextの長さをUChar単位で指定する。-1でNUL終端。
statusUErrorCode*inoutICUエラーコードを入出力するポインタ。呼出前に成功値で初期化する。

戻り値の型: 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, varptr(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, var
; res = ubrk_open(type, locale, text, textLength, status)
; type : UBreakIteratorType -> "int"
; locale : LPCSTR -> "str"
; text : WORD* -> "var"
; textLength : INT -> "int"
; status : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は 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, var
; res = ubrk_open(type, locale, text, textLength, status)
; type : UBreakIteratorType -> "int"
; locale : LPCSTR -> "str"
; text : WORD* -> "var"
; textLength : INT -> "int"
; status : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は 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`,…) を使用。
const std = @import("std");

extern "icuuc" fn ubrk_open(
    type: i32, // UBreakIteratorType
    locale: [*c]const u8, // LPCSTR
    text: [*c]u16, // WORD*
    textLength: i32, // INT
    status: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]isize;
proc ubrk_open(
    `type`: int32,  # UBreakIteratorType
    locale: cstring,  # LPCSTR
    text: ptr uint16,  # WORD*
    textLength: int32,  # INT
    status: ptr int32  # UErrorCode* in/out
): ptr int {.importc: "ubrk_open", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
ptrdiff_t* ubrk_open(
    int type,   // UBreakIteratorType
    const(char)* locale,   // LPCSTR
    ushort* text,   // WORD*
    int textLength,   // INT
    int* status   // UErrorCode* in/out
);
ccall((:ubrk_open, "icuuc.dll"), Ptr{Int},
      (Int32, Cstring, Ptr{UInt16}, Int32, Ptr{Int32}),
      type, locale, text, textLength, status)
# type : UBreakIteratorType -> Int32
# locale : LPCSTR -> Cstring
# text : WORD* -> Ptr{UInt16}
# textLength : INT -> Int32
# status : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
intptr_t* ubrk_open(
    int32_t type,
    const char* locale,
    uint16_t* text,
    int32_t textLength,
    int32_t* status);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ubrk_open(type, locale, text, textLength, status)
-- type : UBreakIteratorType
-- locale : LPCSTR
-- text : WORD*
-- textLength : INT
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const ubrk_open = lib.func('__cdecl', 'ubrk_open', 'intptr_t *', ['int32_t', 'str', 'uint16_t *', 'int32_t', 'int32_t *']);
// ubrk_open(type, locale, text, textLength, status)
// type : UBreakIteratorType -> 'int32_t'
// locale : LPCSTR -> 'str'
// text : WORD* -> 'uint16_t *'
// textLength : INT -> 'int32_t'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  ubrk_open: { parameters: ["i32", "buffer", "pointer", "i32", "pointer"], result: "pointer" },
});
// lib.symbols.ubrk_open(type, locale, text, textLength, status)
// type : UBreakIteratorType -> "i32"
// locale : LPCSTR -> "buffer"
// text : WORD* -> "pointer"
// textLength : INT -> "i32"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
intptr_t* ubrk_open(
    int32_t type,
    const char* locale,
    uint16_t* text,
    int32_t textLength,
    int32_t* status);
C, "icuuc.dll");
// $ffi->ubrk_open(type, locale, text, textLength, status);
// type : UBreakIteratorType
// locale : LPCSTR
// text : WORD*
// textLength : INT
// 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);
    Pointer ubrk_open(
        int type,   // UBreakIteratorType
        String locale,   // LPCSTR
        ShortByReference text,   // WORD*
        int textLength,   // INT
        IntByReference status   // UErrorCode* in/out
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun ubrk_open = ubrk_open(
    type_ : Int32,   # UBreakIteratorType
    locale : UInt8*,   # LPCSTR
    text : UInt16*,   # WORD*
    textLength : Int32,   # INT
    status : Int32*   # UErrorCode* in/out
  ) : LibC::SSizeT*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ubrk_openNative = Pointer<IntPtr> Function(Int32, Pointer<Utf8>, Pointer<Uint16>, Int32, Pointer<Int32>);
typedef ubrk_openDart = Pointer<IntPtr> Function(int, Pointer<Utf8>, Pointer<Uint16>, int, Pointer<Int32>);
final ubrk_open = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<ubrk_openNative, ubrk_openDart>('ubrk_open');
// type : UBreakIteratorType -> Int32
// locale : LPCSTR -> Pointer<Utf8>
// text : WORD* -> Pointer<Uint16>
// textLength : INT -> Int32
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "ubrk_open"
  c_ubrk_open :: Int32 -> CString -> Ptr Word16 -> Int32 -> Ptr Int32 -> IO (Ptr CIntPtr)
-- type : UBreakIteratorType -> Int32
-- locale : LPCSTR -> CString
-- text : WORD* -> Ptr Word16
-- textLength : INT -> Int32
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

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

関連項目

使用する型