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

ucol_strcollUTF8

関数
二つのUTF-8文字列を照合規則で比較する。
DLLicuin.dll呼出規約cdecl

シグネチャ

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

UCollationResult ucol_strcollUTF8(
    const UCollator* coll,
    LPCSTR source,
    INT sourceLength,
    LPCSTR target,
    INT targetLength,
    UErrorCode* status
);

パラメーター

名前方向説明
collUCollator*in比較に用いる照合器(UCollator)を指す。
sourceLPCSTRin比較元のUTF-8文字列を指す。
sourceLengthINTinsourceの長さをバイト単位で指定する。-1でNUL終端。
targetLPCSTRin比較先のUTF-8文字列を指す。
targetLengthINTintargetの長さをバイト単位で指定する。-1でNUL終端。
statusUErrorCode*inoutICUエラーコードを入出力するポインタ。呼出前に成功値で初期化する。

戻り値の型: UCollationResult

各言語での呼び出し定義

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

UCollationResult ucol_strcollUTF8(
    const UCollator* coll,
    LPCSTR source,
    INT sourceLength,
    LPCSTR target,
    INT targetLength,
    UErrorCode* status
);
[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ucol_strcollUTF8(
    ref IntPtr coll,   // UCollator*
    [MarshalAs(UnmanagedType.LPStr)] string source,   // LPCSTR
    int sourceLength,   // INT
    [MarshalAs(UnmanagedType.LPStr)] string target,   // LPCSTR
    int targetLength,   // INT
    ref int status   // UErrorCode* in/out
);
<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucol_strcollUTF8(
    ByRef coll As IntPtr,   ' UCollator*
    <MarshalAs(UnmanagedType.LPStr)> source As String,   ' LPCSTR
    sourceLength As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPStr)> target As String,   ' LPCSTR
    targetLength As Integer,   ' INT
    ByRef status As Integer   ' UErrorCode* in/out
) As Integer
End Function
' coll : UCollator*
' source : LPCSTR
' sourceLength : INT
' target : LPCSTR
' targetLength : INT
' status : UErrorCode* in/out
Declare PtrSafe Function ucol_strcollUTF8 Lib "icuin" ( _
    ByRef coll As LongPtr, _
    ByVal source As String, _
    ByVal sourceLength As Long, _
    ByVal target As String, _
    ByVal targetLength As Long, _
    ByRef status As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ucol_strcollUTF8 = ctypes.cdll.icuin.ucol_strcollUTF8
ucol_strcollUTF8.restype = ctypes.c_int
ucol_strcollUTF8.argtypes = [
    ctypes.c_void_p,  # coll : UCollator*
    wintypes.LPCSTR,  # source : LPCSTR
    ctypes.c_int,  # sourceLength : INT
    wintypes.LPCSTR,  # target : LPCSTR
    ctypes.c_int,  # targetLength : INT
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procucol_strcollUTF8 = icuin.NewProc("ucol_strcollUTF8")
)

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

typedef ucol_strcollUTF8Native = Int32 Function(Pointer<IntPtr>, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Int32>);
typedef ucol_strcollUTF8Dart = int Function(Pointer<IntPtr>, Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Int32>);
final ucol_strcollUTF8 = DynamicLibrary.open('icuin.dll')
    .lookupFunction<ucol_strcollUTF8Native, ucol_strcollUTF8Dart>('ucol_strcollUTF8');
// coll : UCollator* -> Pointer<IntPtr>
// source : LPCSTR -> Pointer<Utf8>
// sourceLength : INT -> Int32
// target : LPCSTR -> Pointer<Utf8>
// targetLength : INT -> Int32
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ucol_strcollUTF8(
  coll: Pointer;   // UCollator*
  source: PAnsiChar;   // LPCSTR
  sourceLength: Integer;   // INT
  target: PAnsiChar;   // LPCSTR
  targetLength: Integer;   // INT
  status: Pointer   // UErrorCode* in/out
): Integer; cdecl;
  external 'icuin.dll' name 'ucol_strcollUTF8';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "ucol_strcollUTF8"
  c_ucol_strcollUTF8 :: Ptr CIntPtr -> CString -> Int32 -> CString -> Int32 -> Ptr Int32 -> IO Int32
-- coll : UCollator* -> Ptr CIntPtr
-- source : LPCSTR -> CString
-- sourceLength : INT -> Int32
-- target : LPCSTR -> CString
-- targetLength : INT -> Int32
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ucol_strcollutf8 =
  foreign "ucol_strcollUTF8"
    ((ptr intptr_t) @-> string @-> int32_t @-> string @-> int32_t @-> (ptr int32_t) @-> returning int32_t)
(* coll : UCollator* -> (ptr intptr_t) *)
(* source : LPCSTR -> string *)
(* sourceLength : INT -> int32_t *)
(* target : LPCSTR -> string *)
(* targetLength : INT -> int32_t *)
(* status : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuin (t "icuin.dll"))
(cffi:use-foreign-library icuin)

(cffi:defcfun ("ucol_strcollUTF8" ucol-strcoll-utf8 :convention :cdecl) :int32
  (coll :pointer)   ; UCollator*
  (source :string)   ; LPCSTR
  (source-length :int32)   ; INT
  (target :string)   ; LPCSTR
  (target-length :int32)   ; INT
  (status :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ucol_strcollUTF8 = Win32::API::More->new('icuin',
    'int ucol_strcollUTF8(LPVOID coll, LPCSTR source, int sourceLength, LPCSTR target, int targetLength, LPVOID status)');
# my $ret = $ucol_strcollUTF8->Call($coll, $source, $sourceLength, $target, $targetLength, $status);
# coll : UCollator* -> LPVOID
# source : LPCSTR -> LPCSTR
# sourceLength : INT -> int
# target : LPCSTR -> LPCSTR
# targetLength : INT -> int
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型