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

ucol_strcoll

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

シグネチャ

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

UCollationResult ucol_strcoll(
    const UCollator* coll,
    const WORD* source,
    INT sourceLength,
    const WORD* target,
    INT targetLength
);

パラメーター

名前方向説明
collUCollator*in比較に用いる照合器(UCollator)を指す。
sourceWORD*in比較元のUTF-16文字列を指す。
sourceLengthINTinsourceの長さをUChar単位で指定する。-1でNUL終端。
targetWORD*in比較先のUTF-16文字列を指す。
targetLengthINTintargetの長さをUChar単位で指定する。-1でNUL終端。

戻り値の型: UCollationResult

各言語での呼び出し定義

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

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

ucol_strcoll = ctypes.cdll.icuin.ucol_strcoll
ucol_strcoll.restype = ctypes.c_int
ucol_strcoll.argtypes = [
    ctypes.c_void_p,  # coll : UCollator*
    ctypes.POINTER(ctypes.c_ushort),  # source : WORD*
    ctypes.c_int,  # sourceLength : INT
    ctypes.POINTER(ctypes.c_ushort),  # target : WORD*
    ctypes.c_int,  # targetLength : INT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procucol_strcoll = icuin.NewProc("ucol_strcoll")
)

// coll (UCollator*), source (WORD*), sourceLength (INT), target (WORD*), targetLength (INT)
r1, _, err := procucol_strcoll.Call(
	uintptr(coll),
	uintptr(source),
	uintptr(sourceLength),
	uintptr(target),
	uintptr(targetLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // UCollationResult
function ucol_strcoll(
  coll: Pointer;   // UCollator*
  source: Pointer;   // WORD*
  sourceLength: Integer;   // INT
  target: Pointer;   // WORD*
  targetLength: Integer   // INT
): Integer; cdecl;
  external 'icuin.dll' name 'ucol_strcoll';
result := DllCall("icuin\ucol_strcoll"
    , "Ptr", coll   ; UCollator*
    , "Ptr", source   ; WORD*
    , "Int", sourceLength   ; INT
    , "Ptr", target   ; WORD*
    , "Int", targetLength   ; INT
    , "Cdecl Int")   ; return: UCollationResult
●ucol_strcoll(coll, source, sourceLength, target, targetLength) = DLL("icuin.dll", "int ucol_strcoll(void*, void*, int, void*, int)")
# 呼び出し: ucol_strcoll(coll, source, sourceLength, target, targetLength)
# coll : UCollator* -> "void*"
# source : WORD* -> "void*"
# sourceLength : INT -> "int"
# target : WORD* -> "void*"
# targetLength : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。
const std = @import("std");

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

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

foreign import ccall safe "ucol_strcoll"
  c_ucol_strcoll :: Ptr CIntPtr -> Ptr Word16 -> Int32 -> Ptr Word16 -> Int32 -> IO Int32
-- coll : UCollator* -> Ptr CIntPtr
-- source : WORD* -> Ptr Word16
-- sourceLength : INT -> Int32
-- target : WORD* -> Ptr Word16
-- targetLength : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ucol_strcoll =
  foreign "ucol_strcoll"
    ((ptr intptr_t) @-> (ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> returning int32_t)
(* coll : UCollator* -> (ptr intptr_t) *)
(* source : WORD* -> (ptr uint16_t) *)
(* sourceLength : INT -> int32_t *)
(* target : WORD* -> (ptr uint16_t) *)
(* targetLength : INT -> 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_strcoll" ucol-strcoll :convention :cdecl) :int32
  (coll :pointer)   ; UCollator*
  (source :pointer)   ; WORD*
  (source-length :int32)   ; INT
  (target :pointer)   ; WORD*
  (target-length :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ucol_strcoll = Win32::API::More->new('icuin',
    'int ucol_strcoll(LPVOID coll, LPVOID source, int sourceLength, LPVOID target, int targetLength)');
# my $ret = $ucol_strcoll->Call($coll, $source, $sourceLength, $target, $targetLength);
# coll : UCollator* -> LPVOID
# source : WORD* -> LPVOID
# sourceLength : INT -> int
# target : WORD* -> LPVOID
# targetLength : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型