ホーム › Globalization › udatpg_getFieldDisplayName
udatpg_getFieldDisplayName
関数指定フィールドの表示名を幅指定で取得する。
シグネチャ
// icu.dll
#include <windows.h>
INT udatpg_getFieldDisplayName(
const void** dtpg,
UDateTimePatternField field,
UDateTimePGDisplayWidth width,
WORD* fieldName,
INT capacity,
UErrorCode* pErrorCode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dtpg | void** | in | 対象のUDateTimePatternGeneratorハンドル。 |
| field | UDateTimePatternField | in | 表示名を取得する日時パターンフィールドを示す列挙値。 |
| width | UDateTimePGDisplayWidth | in | 取得する表示名の幅(完全形・短縮形等)を示す列挙値。 |
| fieldName | WORD* | inout | フィールド表示名を受け取る出力バッファ。UTF-16配列。 |
| capacity | INT | in | 出力バッファの容量(UTF-16単位)。0で必要長の照会も可能。 |
| pErrorCode | UErrorCode* | inout | ICUのエラーコード。呼び出し前に成功値で初期化する。 |
戻り値の型: INT
各言語での呼び出し定義
// icu.dll
#include <windows.h>
INT udatpg_getFieldDisplayName(
const void** dtpg,
UDateTimePatternField field,
UDateTimePGDisplayWidth width,
WORD* fieldName,
INT capacity,
UErrorCode* pErrorCode
);[DllImport("icu.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int udatpg_getFieldDisplayName(
IntPtr dtpg, // void**
int field, // UDateTimePatternField
int width, // UDateTimePGDisplayWidth
ref ushort fieldName, // WORD* in/out
int capacity, // INT
ref int pErrorCode // UErrorCode* in/out
);<DllImport("icu.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function udatpg_getFieldDisplayName(
dtpg As IntPtr, ' void**
field As Integer, ' UDateTimePatternField
width As Integer, ' UDateTimePGDisplayWidth
ByRef fieldName As UShort, ' WORD* in/out
capacity As Integer, ' INT
ByRef pErrorCode As Integer ' UErrorCode* in/out
) As Integer
End Function' dtpg : void**
' field : UDateTimePatternField
' width : UDateTimePGDisplayWidth
' fieldName : WORD* in/out
' capacity : INT
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function udatpg_getFieldDisplayName Lib "icu" ( _
ByVal dtpg As LongPtr, _
ByVal field As Long, _
ByVal width As Long, _
ByRef fieldName As Integer, _
ByVal capacity As Long, _
ByRef pErrorCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
udatpg_getFieldDisplayName = ctypes.cdll.icu.udatpg_getFieldDisplayName
udatpg_getFieldDisplayName.restype = ctypes.c_int
udatpg_getFieldDisplayName.argtypes = [
ctypes.c_void_p, # dtpg : void**
ctypes.c_int, # field : UDateTimePatternField
ctypes.c_int, # width : UDateTimePGDisplayWidth
ctypes.POINTER(ctypes.c_ushort), # fieldName : WORD* in/out
ctypes.c_int, # capacity : INT
ctypes.c_void_p, # pErrorCode : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icu.dll')
udatpg_getFieldDisplayName = Fiddle::Function.new(
lib['udatpg_getFieldDisplayName'],
[
Fiddle::TYPE_VOIDP, # dtpg : void**
Fiddle::TYPE_INT, # field : UDateTimePatternField
Fiddle::TYPE_INT, # width : UDateTimePGDisplayWidth
Fiddle::TYPE_VOIDP, # fieldName : WORD* in/out
Fiddle::TYPE_INT, # capacity : INT
Fiddle::TYPE_VOIDP, # pErrorCode : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icu")]
extern "C" {
fn udatpg_getFieldDisplayName(
dtpg: *const *const (), // void**
field: i32, // UDateTimePatternField
width: i32, // UDateTimePGDisplayWidth
fieldName: *mut u16, // WORD* in/out
capacity: i32, // INT
pErrorCode: *mut i32 // UErrorCode* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icu.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int udatpg_getFieldDisplayName(IntPtr dtpg, int field, int width, ref ushort fieldName, int capacity, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icu_udatpg_getFieldDisplayName' -Namespace Win32 -PassThru
# $api::udatpg_getFieldDisplayName(dtpg, field, width, fieldName, capacity, pErrorCode)#uselib "icu.dll"
#func global udatpg_getFieldDisplayName "udatpg_getFieldDisplayName" sptr, sptr, sptr, sptr, sptr, sptr
; udatpg_getFieldDisplayName dtpg, field, width, varptr(fieldName), capacity, varptr(pErrorCode) ; 戻り値は stat
; dtpg : void** -> "sptr"
; field : UDateTimePatternField -> "sptr"
; width : UDateTimePGDisplayWidth -> "sptr"
; fieldName : WORD* in/out -> "sptr"
; capacity : INT -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icu.dll" #cfunc global udatpg_getFieldDisplayName "udatpg_getFieldDisplayName" sptr, int, int, var, int, var ; res = udatpg_getFieldDisplayName(dtpg, field, width, fieldName, capacity, pErrorCode) ; dtpg : void** -> "sptr" ; field : UDateTimePatternField -> "int" ; width : UDateTimePGDisplayWidth -> "int" ; fieldName : WORD* in/out -> "var" ; capacity : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icu.dll" #cfunc global udatpg_getFieldDisplayName "udatpg_getFieldDisplayName" sptr, int, int, sptr, int, sptr ; res = udatpg_getFieldDisplayName(dtpg, field, width, varptr(fieldName), capacity, varptr(pErrorCode)) ; dtpg : void** -> "sptr" ; field : UDateTimePatternField -> "int" ; width : UDateTimePGDisplayWidth -> "int" ; fieldName : WORD* in/out -> "sptr" ; capacity : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT udatpg_getFieldDisplayName(void** dtpg, UDateTimePatternField field, UDateTimePGDisplayWidth width, WORD* fieldName, INT capacity, UErrorCode* pErrorCode) #uselib "icu.dll" #cfunc global udatpg_getFieldDisplayName "udatpg_getFieldDisplayName" intptr, int, int, var, int, var ; res = udatpg_getFieldDisplayName(dtpg, field, width, fieldName, capacity, pErrorCode) ; dtpg : void** -> "intptr" ; field : UDateTimePatternField -> "int" ; width : UDateTimePGDisplayWidth -> "int" ; fieldName : WORD* in/out -> "var" ; capacity : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT udatpg_getFieldDisplayName(void** dtpg, UDateTimePatternField field, UDateTimePGDisplayWidth width, WORD* fieldName, INT capacity, UErrorCode* pErrorCode) #uselib "icu.dll" #cfunc global udatpg_getFieldDisplayName "udatpg_getFieldDisplayName" intptr, int, int, intptr, int, intptr ; res = udatpg_getFieldDisplayName(dtpg, field, width, varptr(fieldName), capacity, varptr(pErrorCode)) ; dtpg : void** -> "intptr" ; field : UDateTimePatternField -> "int" ; width : UDateTimePGDisplayWidth -> "int" ; fieldName : WORD* in/out -> "intptr" ; capacity : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icu = windows.NewLazySystemDLL("icu.dll")
procudatpg_getFieldDisplayName = icu.NewProc("udatpg_getFieldDisplayName")
)
// dtpg (void**), field (UDateTimePatternField), width (UDateTimePGDisplayWidth), fieldName (WORD* in/out), capacity (INT), pErrorCode (UErrorCode* in/out)
r1, _, err := procudatpg_getFieldDisplayName.Call(
uintptr(dtpg),
uintptr(field),
uintptr(width),
uintptr(fieldName),
uintptr(capacity),
uintptr(pErrorCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction udatpg_getFieldDisplayName(
dtpg: Pointer; // void**
field: Integer; // UDateTimePatternField
width: Integer; // UDateTimePGDisplayWidth
fieldName: Pointer; // WORD* in/out
capacity: Integer; // INT
pErrorCode: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icu.dll' name 'udatpg_getFieldDisplayName';result := DllCall("icu\udatpg_getFieldDisplayName"
, "Ptr", dtpg ; void**
, "Int", field ; UDateTimePatternField
, "Int", width ; UDateTimePGDisplayWidth
, "Ptr", fieldName ; WORD* in/out
, "Int", capacity ; INT
, "Ptr", pErrorCode ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●udatpg_getFieldDisplayName(dtpg, field, width, fieldName, capacity, pErrorCode) = DLL("icu.dll", "int udatpg_getFieldDisplayName(void*, int, int, void*, int, void*)")
# 呼び出し: udatpg_getFieldDisplayName(dtpg, field, width, fieldName, capacity, pErrorCode)
# dtpg : void** -> "void*"
# field : UDateTimePatternField -> "int"
# width : UDateTimePGDisplayWidth -> "int"
# fieldName : WORD* in/out -> "void*"
# capacity : INT -> "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 "icu" fn udatpg_getFieldDisplayName(
dtpg: ?*anyopaque, // void**
field: i32, // UDateTimePatternField
width: i32, // UDateTimePGDisplayWidth
fieldName: [*c]u16, // WORD* in/out
capacity: i32, // INT
pErrorCode: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc udatpg_getFieldDisplayName(
dtpg: pointer, # void**
field: int32, # UDateTimePatternField
width: int32, # UDateTimePGDisplayWidth
fieldName: ptr uint16, # WORD* in/out
capacity: int32, # INT
pErrorCode: ptr int32 # UErrorCode* in/out
): int32 {.importc: "udatpg_getFieldDisplayName", cdecl, dynlib: "icu.dll".}pragma(lib, "icu");
extern(C)
int udatpg_getFieldDisplayName(
void** dtpg, // void**
int field, // UDateTimePatternField
int width, // UDateTimePGDisplayWidth
ushort* fieldName, // WORD* in/out
int capacity, // INT
int* pErrorCode // UErrorCode* in/out
);ccall((:udatpg_getFieldDisplayName, "icu.dll"), Int32,
(Ptr{Cvoid}, Int32, Int32, Ptr{UInt16}, Int32, Ptr{Int32}),
dtpg, field, width, fieldName, capacity, pErrorCode)
# dtpg : void** -> Ptr{Cvoid}
# field : UDateTimePatternField -> Int32
# width : UDateTimePGDisplayWidth -> Int32
# fieldName : WORD* in/out -> Ptr{UInt16}
# capacity : INT -> Int32
# pErrorCode : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t udatpg_getFieldDisplayName(
void** dtpg,
int32_t field,
int32_t width,
uint16_t* fieldName,
int32_t capacity,
int32_t* pErrorCode);
]]
local icu = ffi.load("icu")
-- icu.udatpg_getFieldDisplayName(dtpg, field, width, fieldName, capacity, pErrorCode)
-- dtpg : void**
-- field : UDateTimePatternField
-- width : UDateTimePGDisplayWidth
-- fieldName : WORD* in/out
-- capacity : INT
-- pErrorCode : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icu.dll');
const udatpg_getFieldDisplayName = lib.func('__cdecl', 'udatpg_getFieldDisplayName', 'int32_t', ['void *', 'int32_t', 'int32_t', 'uint16_t *', 'int32_t', 'int32_t *']);
// udatpg_getFieldDisplayName(dtpg, field, width, fieldName, capacity, pErrorCode)
// dtpg : void** -> 'void *'
// field : UDateTimePatternField -> 'int32_t'
// width : UDateTimePGDisplayWidth -> 'int32_t'
// fieldName : WORD* in/out -> 'uint16_t *'
// capacity : INT -> 'int32_t'
// pErrorCode : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icu.dll", {
udatpg_getFieldDisplayName: { parameters: ["pointer", "i32", "i32", "pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.udatpg_getFieldDisplayName(dtpg, field, width, fieldName, capacity, pErrorCode)
// dtpg : void** -> "pointer"
// field : UDateTimePatternField -> "i32"
// width : UDateTimePGDisplayWidth -> "i32"
// fieldName : WORD* in/out -> "pointer"
// capacity : INT -> "i32"
// pErrorCode : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t udatpg_getFieldDisplayName(
void** dtpg,
int32_t field,
int32_t width,
uint16_t* fieldName,
int32_t capacity,
int32_t* pErrorCode);
C, "icu.dll");
// $ffi->udatpg_getFieldDisplayName(dtpg, field, width, fieldName, capacity, pErrorCode);
// dtpg : void**
// field : UDateTimePatternField
// width : UDateTimePGDisplayWidth
// fieldName : WORD* in/out
// capacity : INT
// 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 Icu extends Library {
Icu INSTANCE = Native.load("icu", Icu.class);
int udatpg_getFieldDisplayName(
Pointer dtpg, // void**
int field, // UDateTimePatternField
int width, // UDateTimePGDisplayWidth
ShortByReference fieldName, // WORD* in/out
int capacity, // INT
IntByReference pErrorCode // UErrorCode* in/out
);
}@[Link("icu")]
lib Libicu
fun udatpg_getFieldDisplayName = udatpg_getFieldDisplayName(
dtpg : Void**, # void**
field : Int32, # UDateTimePatternField
width : Int32, # UDateTimePGDisplayWidth
fieldName : UInt16*, # WORD* in/out
capacity : Int32, # INT
pErrorCode : Int32* # UErrorCode* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef udatpg_getFieldDisplayNameNative = Int32 Function(Pointer<Void>, Int32, Int32, Pointer<Uint16>, Int32, Pointer<Int32>);
typedef udatpg_getFieldDisplayNameDart = int Function(Pointer<Void>, int, int, Pointer<Uint16>, int, Pointer<Int32>);
final udatpg_getFieldDisplayName = DynamicLibrary.open('icu.dll')
.lookupFunction<udatpg_getFieldDisplayNameNative, udatpg_getFieldDisplayNameDart>('udatpg_getFieldDisplayName');
// dtpg : void** -> Pointer<Void>
// field : UDateTimePatternField -> Int32
// width : UDateTimePGDisplayWidth -> Int32
// fieldName : WORD* in/out -> Pointer<Uint16>
// capacity : INT -> Int32
// pErrorCode : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function udatpg_getFieldDisplayName(
dtpg: Pointer; // void**
field: Integer; // UDateTimePatternField
width: Integer; // UDateTimePGDisplayWidth
fieldName: Pointer; // WORD* in/out
capacity: Integer; // INT
pErrorCode: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icu.dll' name 'udatpg_getFieldDisplayName';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "udatpg_getFieldDisplayName"
c_udatpg_getFieldDisplayName :: Ptr () -> Int32 -> Int32 -> Ptr Word16 -> Int32 -> Ptr Int32 -> IO Int32
-- dtpg : void** -> Ptr ()
-- field : UDateTimePatternField -> Int32
-- width : UDateTimePGDisplayWidth -> Int32
-- fieldName : WORD* in/out -> Ptr Word16
-- capacity : INT -> Int32
-- pErrorCode : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let udatpg_getfielddisplayname =
foreign "udatpg_getFieldDisplayName"
((ptr void) @-> int32_t @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> (ptr int32_t) @-> returning int32_t)
(* dtpg : void** -> (ptr void) *)
(* field : UDateTimePatternField -> int32_t *)
(* width : UDateTimePGDisplayWidth -> int32_t *)
(* fieldName : WORD* in/out -> (ptr uint16_t) *)
(* capacity : INT -> int32_t *)
(* pErrorCode : 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 ("udatpg_getFieldDisplayName" udatpg-get-field-display-name :convention :cdecl) :int32
(dtpg :pointer) ; void**
(field :int32) ; UDateTimePatternField
(width :int32) ; UDateTimePGDisplayWidth
(field-name :pointer) ; WORD* in/out
(capacity :int32) ; INT
(p-error-code :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $udatpg_getFieldDisplayName = Win32::API::More->new('icu',
'int udatpg_getFieldDisplayName(LPVOID dtpg, int field, int width, LPVOID fieldName, int capacity, LPVOID pErrorCode)');
# my $ret = $udatpg_getFieldDisplayName->Call($dtpg, $field, $width, $fieldName, $capacity, $pErrorCode);
# dtpg : void** -> LPVOID
# field : UDateTimePatternField -> int
# width : UDateTimePGDisplayWidth -> int
# fieldName : WORD* in/out -> LPVOID
# capacity : INT -> int
# pErrorCode : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。