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

ufmtval_getString

関数
整形済み値の文字列表現を取得する。
DLLicu.dll呼出規約cdecl

シグネチャ

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

WORD* ufmtval_getString(
    const UFormattedValue* ufmtval,
    INT* pLength,
    UErrorCode* ec
);

パラメーター

名前方向説明
ufmtvalUFormattedValue*in書式化済み文字列を取得する書式化結果値のハンドル。
pLengthINT*inout返される文字列の長さ(UChar単位)を受け取る出力ポインタ。NULL可。
ecUErrorCode*inoutエラーコードへのポインタ。呼び出し前に初期化する必要がある。

戻り値の型: WORD*

各言語での呼び出し定義

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

WORD* ufmtval_getString(
    const UFormattedValue* ufmtval,
    INT* pLength,
    UErrorCode* ec
);
[DllImport("icu.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ufmtval_getString(
    ref IntPtr ufmtval,   // UFormattedValue*
    ref int pLength,   // INT* in/out
    ref int ec   // UErrorCode* in/out
);
<DllImport("icu.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ufmtval_getString(
    ByRef ufmtval As IntPtr,   ' UFormattedValue*
    ByRef pLength As Integer,   ' INT* in/out
    ByRef ec As Integer   ' UErrorCode* in/out
) As IntPtr
End Function
' ufmtval : UFormattedValue*
' pLength : INT* in/out
' ec : UErrorCode* in/out
Declare PtrSafe Function ufmtval_getString Lib "icu" ( _
    ByRef ufmtval As LongPtr, _
    ByRef pLength As Long, _
    ByRef ec As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ufmtval_getString = ctypes.cdll.icu.ufmtval_getString
ufmtval_getString.restype = ctypes.c_void_p
ufmtval_getString.argtypes = [
    ctypes.c_void_p,  # ufmtval : UFormattedValue*
    ctypes.POINTER(ctypes.c_int),  # pLength : INT* in/out
    ctypes.c_void_p,  # ec : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icu = windows.NewLazySystemDLL("icu.dll")
	procufmtval_getString = icu.NewProc("ufmtval_getString")
)

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

typedef ufmtval_getStringNative = Pointer<Uint16> Function(Pointer<IntPtr>, Pointer<Int32>, Pointer<Int32>);
typedef ufmtval_getStringDart = Pointer<Uint16> Function(Pointer<IntPtr>, Pointer<Int32>, Pointer<Int32>);
final ufmtval_getString = DynamicLibrary.open('icu.dll')
    .lookupFunction<ufmtval_getStringNative, ufmtval_getStringDart>('ufmtval_getString');
// ufmtval : UFormattedValue* -> Pointer<IntPtr>
// pLength : INT* in/out -> Pointer<Int32>
// ec : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ufmtval_getString(
  ufmtval: Pointer;   // UFormattedValue*
  pLength: Pointer;   // INT* in/out
  ec: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icu.dll' name 'ufmtval_getString';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "ufmtval_getString"
  c_ufmtval_getString :: Ptr CIntPtr -> Ptr Int32 -> Ptr Int32 -> IO (Ptr Word16)
-- ufmtval : UFormattedValue* -> Ptr CIntPtr
-- pLength : INT* in/out -> Ptr Int32
-- ec : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ufmtval_getstring =
  foreign "ufmtval_getString"
    ((ptr intptr_t) @-> (ptr int32_t) @-> (ptr int32_t) @-> returning (ptr uint16_t))
(* ufmtval : UFormattedValue* -> (ptr intptr_t) *)
(* pLength : INT* in/out -> (ptr int32_t) *)
(* ec : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icu (t "icu.dll"))
(cffi:use-foreign-library icu)

(cffi:defcfun ("ufmtval_getString" ufmtval-get-string :convention :cdecl) :pointer
  (ufmtval :pointer)   ; UFormattedValue*
  (p-length :pointer)   ; INT* in/out
  (ec :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ufmtval_getString = Win32::API::More->new('icu',
    'LPVOID ufmtval_getString(LPVOID ufmtval, LPVOID pLength, LPVOID ec)');
# my $ret = $ufmtval_getString->Call($ufmtval, $pLength, $ec);
# ufmtval : UFormattedValue* -> LPVOID
# pLength : INT* in/out -> LPVOID
# ec : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型