ホーム › Globalization › ubidi_writeReverse
ubidi_writeReverse
関数文字列を逆順に並べ替えて書き出す。
シグネチャ
// icuuc.dll
#include <windows.h>
INT ubidi_writeReverse(
const WORD* src,
INT srcLength,
WORD* dest,
INT destSize,
WORD options,
UErrorCode* pErrorCode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| src | WORD* | in | 逆順化する入力テキスト(UTF-16文字列)へのポインタ。 |
| srcLength | INT | in | srcの長さ(UChar単位)。 |
| dest | WORD* | inout | 逆順化結果を書き込む出力バッファ(UTF-16)。 |
| destSize | INT | in | destの容量(UChar単位)。 |
| options | WORD | in | 逆順化時の制御オプションのビットフラグ(結合文字保持等)。 |
| pErrorCode | UErrorCode* | inout | ICUのエラーコードを受け渡すポインタ。呼び出し前にU_ZERO_ERRORで初期化する。 |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT ubidi_writeReverse(
const WORD* src,
INT srcLength,
WORD* dest,
INT destSize,
WORD options,
UErrorCode* pErrorCode
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ubidi_writeReverse(
ref ushort src, // WORD*
int srcLength, // INT
ref ushort dest, // WORD* in/out
int destSize, // INT
ushort options, // WORD
ref int pErrorCode // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ubidi_writeReverse(
ByRef src As UShort, ' WORD*
srcLength As Integer, ' INT
ByRef dest As UShort, ' WORD* in/out
destSize As Integer, ' INT
options As UShort, ' WORD
ByRef pErrorCode As Integer ' UErrorCode* in/out
) As Integer
End Function' src : WORD*
' srcLength : INT
' dest : WORD* in/out
' destSize : INT
' options : WORD
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function ubidi_writeReverse Lib "icuuc" ( _
ByRef src As Integer, _
ByVal srcLength As Long, _
ByRef dest As Integer, _
ByVal destSize As Long, _
ByVal options As Integer, _
ByRef pErrorCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ubidi_writeReverse = ctypes.cdll.icuuc.ubidi_writeReverse
ubidi_writeReverse.restype = ctypes.c_int
ubidi_writeReverse.argtypes = [
ctypes.POINTER(ctypes.c_ushort), # src : WORD*
ctypes.c_int, # srcLength : INT
ctypes.POINTER(ctypes.c_ushort), # dest : WORD* in/out
ctypes.c_int, # destSize : INT
ctypes.c_ushort, # options : WORD
ctypes.c_void_p, # pErrorCode : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
ubidi_writeReverse = Fiddle::Function.new(
lib['ubidi_writeReverse'],
[
Fiddle::TYPE_VOIDP, # src : WORD*
Fiddle::TYPE_INT, # srcLength : INT
Fiddle::TYPE_VOIDP, # dest : WORD* in/out
Fiddle::TYPE_INT, # destSize : INT
-Fiddle::TYPE_SHORT, # options : WORD
Fiddle::TYPE_VOIDP, # pErrorCode : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn ubidi_writeReverse(
src: *const u16, // WORD*
srcLength: i32, // INT
dest: *mut u16, // WORD* in/out
destSize: i32, // INT
options: u16, // WORD
pErrorCode: *mut i32 // UErrorCode* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int ubidi_writeReverse(ref ushort src, int srcLength, ref ushort dest, int destSize, ushort options, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ubidi_writeReverse' -Namespace Win32 -PassThru
# $api::ubidi_writeReverse(src, srcLength, dest, destSize, options, pErrorCode)#uselib "icuuc.dll"
#func global ubidi_writeReverse "ubidi_writeReverse" sptr, sptr, sptr, sptr, sptr, sptr
; ubidi_writeReverse varptr(src), srcLength, varptr(dest), destSize, options, varptr(pErrorCode) ; 戻り値は stat
; src : WORD* -> "sptr"
; srcLength : INT -> "sptr"
; dest : WORD* in/out -> "sptr"
; destSize : INT -> "sptr"
; options : WORD -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global ubidi_writeReverse "ubidi_writeReverse" var, int, var, int, int, var ; res = ubidi_writeReverse(src, srcLength, dest, destSize, options, pErrorCode) ; src : WORD* -> "var" ; srcLength : INT -> "int" ; dest : WORD* in/out -> "var" ; destSize : INT -> "int" ; options : WORD -> "int" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global ubidi_writeReverse "ubidi_writeReverse" sptr, int, sptr, int, int, sptr ; res = ubidi_writeReverse(varptr(src), srcLength, varptr(dest), destSize, options, varptr(pErrorCode)) ; src : WORD* -> "sptr" ; srcLength : INT -> "int" ; dest : WORD* in/out -> "sptr" ; destSize : INT -> "int" ; options : WORD -> "int" ; pErrorCode : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT ubidi_writeReverse(WORD* src, INT srcLength, WORD* dest, INT destSize, WORD options, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global ubidi_writeReverse "ubidi_writeReverse" var, int, var, int, int, var ; res = ubidi_writeReverse(src, srcLength, dest, destSize, options, pErrorCode) ; src : WORD* -> "var" ; srcLength : INT -> "int" ; dest : WORD* in/out -> "var" ; destSize : INT -> "int" ; options : WORD -> "int" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT ubidi_writeReverse(WORD* src, INT srcLength, WORD* dest, INT destSize, WORD options, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global ubidi_writeReverse "ubidi_writeReverse" intptr, int, intptr, int, int, intptr ; res = ubidi_writeReverse(varptr(src), srcLength, varptr(dest), destSize, options, varptr(pErrorCode)) ; src : WORD* -> "intptr" ; srcLength : INT -> "int" ; dest : WORD* in/out -> "intptr" ; destSize : INT -> "int" ; options : WORD -> "int" ; pErrorCode : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procubidi_writeReverse = icuuc.NewProc("ubidi_writeReverse")
)
// src (WORD*), srcLength (INT), dest (WORD* in/out), destSize (INT), options (WORD), pErrorCode (UErrorCode* in/out)
r1, _, err := procubidi_writeReverse.Call(
uintptr(src),
uintptr(srcLength),
uintptr(dest),
uintptr(destSize),
uintptr(options),
uintptr(pErrorCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction ubidi_writeReverse(
src: Pointer; // WORD*
srcLength: Integer; // INT
dest: Pointer; // WORD* in/out
destSize: Integer; // INT
options: Word; // WORD
pErrorCode: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'ubidi_writeReverse';result := DllCall("icuuc\ubidi_writeReverse"
, "Ptr", src ; WORD*
, "Int", srcLength ; INT
, "Ptr", dest ; WORD* in/out
, "Int", destSize ; INT
, "UShort", options ; WORD
, "Ptr", pErrorCode ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●ubidi_writeReverse(src, srcLength, dest, destSize, options, pErrorCode) = DLL("icuuc.dll", "int ubidi_writeReverse(void*, int, void*, int, int, void*)")
# 呼び出し: ubidi_writeReverse(src, srcLength, dest, destSize, options, pErrorCode)
# src : WORD* -> "void*"
# srcLength : INT -> "int"
# dest : WORD* in/out -> "void*"
# destSize : INT -> "int"
# options : WORD -> "int"
# pErrorCode : 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 ubidi_writeReverse(
src: [*c]u16, // WORD*
srcLength: i32, // INT
dest: [*c]u16, // WORD* in/out
destSize: i32, // INT
options: u16, // WORD
pErrorCode: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc ubidi_writeReverse(
src: ptr uint16, # WORD*
srcLength: int32, # INT
dest: ptr uint16, # WORD* in/out
destSize: int32, # INT
options: uint16, # WORD
pErrorCode: ptr int32 # UErrorCode* in/out
): int32 {.importc: "ubidi_writeReverse", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
int ubidi_writeReverse(
ushort* src, // WORD*
int srcLength, // INT
ushort* dest, // WORD* in/out
int destSize, // INT
ushort options, // WORD
int* pErrorCode // UErrorCode* in/out
);ccall((:ubidi_writeReverse, "icuuc.dll"), Int32,
(Ptr{UInt16}, Int32, Ptr{UInt16}, Int32, UInt16, Ptr{Int32}),
src, srcLength, dest, destSize, options, pErrorCode)
# src : WORD* -> Ptr{UInt16}
# srcLength : INT -> Int32
# dest : WORD* in/out -> Ptr{UInt16}
# destSize : INT -> Int32
# options : WORD -> UInt16
# pErrorCode : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t ubidi_writeReverse(
uint16_t* src,
int32_t srcLength,
uint16_t* dest,
int32_t destSize,
uint16_t options,
int32_t* pErrorCode);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ubidi_writeReverse(src, srcLength, dest, destSize, options, pErrorCode)
-- src : WORD*
-- srcLength : INT
-- dest : WORD* in/out
-- destSize : INT
-- options : WORD
-- pErrorCode : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const ubidi_writeReverse = lib.func('__cdecl', 'ubidi_writeReverse', 'int32_t', ['uint16_t *', 'int32_t', 'uint16_t *', 'int32_t', 'uint16_t', 'int32_t *']);
// ubidi_writeReverse(src, srcLength, dest, destSize, options, pErrorCode)
// src : WORD* -> 'uint16_t *'
// srcLength : INT -> 'int32_t'
// dest : WORD* in/out -> 'uint16_t *'
// destSize : INT -> 'int32_t'
// options : WORD -> 'uint16_t'
// pErrorCode : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
ubidi_writeReverse: { parameters: ["pointer", "i32", "pointer", "i32", "u16", "pointer"], result: "i32" },
});
// lib.symbols.ubidi_writeReverse(src, srcLength, dest, destSize, options, pErrorCode)
// src : WORD* -> "pointer"
// srcLength : INT -> "i32"
// dest : WORD* in/out -> "pointer"
// destSize : INT -> "i32"
// options : WORD -> "u16"
// pErrorCode : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ubidi_writeReverse(
uint16_t* src,
int32_t srcLength,
uint16_t* dest,
int32_t destSize,
uint16_t options,
int32_t* pErrorCode);
C, "icuuc.dll");
// $ffi->ubidi_writeReverse(src, srcLength, dest, destSize, options, pErrorCode);
// src : WORD*
// srcLength : INT
// dest : WORD* in/out
// destSize : INT
// options : WORD
// pErrorCode : 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);
int ubidi_writeReverse(
ShortByReference src, // WORD*
int srcLength, // INT
ShortByReference dest, // WORD* in/out
int destSize, // INT
short options, // WORD
IntByReference pErrorCode // UErrorCode* in/out
);
}@[Link("icuuc")]
lib Libicuuc
fun ubidi_writeReverse = ubidi_writeReverse(
src : UInt16*, # WORD*
srcLength : Int32, # INT
dest : UInt16*, # WORD* in/out
destSize : Int32, # INT
options : UInt16, # WORD
pErrorCode : Int32* # UErrorCode* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ubidi_writeReverseNative = Int32 Function(Pointer<Uint16>, Int32, Pointer<Uint16>, Int32, Uint16, Pointer<Int32>);
typedef ubidi_writeReverseDart = int Function(Pointer<Uint16>, int, Pointer<Uint16>, int, int, Pointer<Int32>);
final ubidi_writeReverse = DynamicLibrary.open('icuuc.dll')
.lookupFunction<ubidi_writeReverseNative, ubidi_writeReverseDart>('ubidi_writeReverse');
// src : WORD* -> Pointer<Uint16>
// srcLength : INT -> Int32
// dest : WORD* in/out -> Pointer<Uint16>
// destSize : INT -> Int32
// options : WORD -> Uint16
// pErrorCode : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ubidi_writeReverse(
src: Pointer; // WORD*
srcLength: Integer; // INT
dest: Pointer; // WORD* in/out
destSize: Integer; // INT
options: Word; // WORD
pErrorCode: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'ubidi_writeReverse';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ubidi_writeReverse"
c_ubidi_writeReverse :: Ptr Word16 -> Int32 -> Ptr Word16 -> Int32 -> Word16 -> Ptr Int32 -> IO Int32
-- src : WORD* -> Ptr Word16
-- srcLength : INT -> Int32
-- dest : WORD* in/out -> Ptr Word16
-- destSize : INT -> Int32
-- options : WORD -> Word16
-- pErrorCode : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ubidi_writereverse =
foreign "ubidi_writeReverse"
((ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> uint16_t @-> (ptr int32_t) @-> returning int32_t)
(* src : WORD* -> (ptr uint16_t) *)
(* srcLength : INT -> int32_t *)
(* dest : WORD* in/out -> (ptr uint16_t) *)
(* destSize : INT -> int32_t *)
(* options : WORD -> uint16_t *)
(* pErrorCode : 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 ("ubidi_writeReverse" ubidi-write-reverse :convention :cdecl) :int32
(src :pointer) ; WORD*
(src-length :int32) ; INT
(dest :pointer) ; WORD* in/out
(dest-size :int32) ; INT
(options :uint16) ; WORD
(p-error-code :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ubidi_writeReverse = Win32::API::More->new('icuuc',
'int ubidi_writeReverse(LPVOID src, int srcLength, LPVOID dest, int destSize, WORD options, LPVOID pErrorCode)');
# my $ret = $ubidi_writeReverse->Call($src, $srcLength, $dest, $destSize, $options, $pErrorCode);
# src : WORD* -> LPVOID
# srcLength : INT -> int
# dest : WORD* in/out -> LPVOID
# destSize : INT -> int
# options : WORD -> WORD
# pErrorCode : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型