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

unorm2_composePair

関数
二つのコードポイントを合成した文字を返す。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

INT unorm2_composePair(
    const UNormalizer2* norm2,
    INT a,
    INT b
);

パラメーター

名前方向説明
norm2UNormalizer2*in使用する正規化器インスタンス。
aINTin合成元となる第一コードポイント。
bINTin合成元となる第二コードポイント。aとbの合成結果のコードポイントを返し、合成不可なら-1を返す。

戻り値の型: INT

各言語での呼び出し定義

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

INT unorm2_composePair(
    const UNormalizer2* norm2,
    INT a,
    INT b
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int unorm2_composePair(
    ref IntPtr norm2,   // UNormalizer2*
    int a,   // INT
    int b   // INT
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function unorm2_composePair(
    ByRef norm2 As IntPtr,   ' UNormalizer2*
    a As Integer,   ' INT
    b As Integer   ' INT
) As Integer
End Function
' norm2 : UNormalizer2*
' a : INT
' b : INT
Declare PtrSafe Function unorm2_composePair Lib "icuuc" ( _
    ByRef norm2 As LongPtr, _
    ByVal a As Long, _
    ByVal b As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

unorm2_composePair = ctypes.cdll.icuuc.unorm2_composePair
unorm2_composePair.restype = ctypes.c_int
unorm2_composePair.argtypes = [
    ctypes.c_void_p,  # norm2 : UNormalizer2*
    ctypes.c_int,  # a : INT
    ctypes.c_int,  # b : INT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procunorm2_composePair = icuuc.NewProc("unorm2_composePair")
)

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

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

typedef unorm2_composePairNative = Int32 Function(Pointer<IntPtr>, Int32, Int32);
typedef unorm2_composePairDart = int Function(Pointer<IntPtr>, int, int);
final unorm2_composePair = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<unorm2_composePairNative, unorm2_composePairDart>('unorm2_composePair');
// norm2 : UNormalizer2* -> Pointer<IntPtr>
// a : INT -> Int32
// b : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function unorm2_composePair(
  norm2: Pointer;   // UNormalizer2*
  a: Integer;   // INT
  b: Integer   // INT
): Integer; cdecl;
  external 'icuuc.dll' name 'unorm2_composePair';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "unorm2_composePair"
  c_unorm2_composePair :: Ptr CIntPtr -> Int32 -> Int32 -> IO Int32
-- norm2 : UNormalizer2* -> Ptr CIntPtr
-- a : INT -> Int32
-- b : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let unorm2_composepair =
  foreign "unorm2_composePair"
    ((ptr intptr_t) @-> int32_t @-> int32_t @-> returning int32_t)
(* norm2 : UNormalizer2* -> (ptr intptr_t) *)
(* a : INT -> int32_t *)
(* b : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)

(cffi:defcfun ("unorm2_composePair" unorm2-compose-pair :convention :cdecl) :int32
  (norm2 :pointer)   ; UNormalizer2*
  (a :int32)   ; INT
  (b :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $unorm2_composePair = Win32::API::More->new('icuuc',
    'int unorm2_composePair(LPVOID norm2, int a, int b)');
# my $ret = $unorm2_composePair->Call($norm2, $a, $b);
# norm2 : UNormalizer2* -> LPVOID
# a : INT -> int
# b : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。