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

ucnv_fixFileSeparator

関数
EBCDIC系コンバーターでパス区切り文字を修正する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

void ucnv_fixFileSeparator(
    const UConverter* cnv,
    WORD* source,
    INT sourceLen
);

パラメーター

名前方向説明
cnvUConverter*in対象のコンバーターへのポインタ。
sourceWORD*inoutパス区切り文字を正規化するUnicode文字列(UTF-16)へのポインタ。
sourceLenINTinsourceの長さ。

戻り値の型: void

各言語での呼び出し定義

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

void ucnv_fixFileSeparator(
    const UConverter* cnv,
    WORD* source,
    INT sourceLen
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern void ucnv_fixFileSeparator(
    ref IntPtr cnv,   // UConverter*
    ref ushort source,   // WORD* in/out
    int sourceLen   // INT
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub ucnv_fixFileSeparator(
    ByRef cnv As IntPtr,   ' UConverter*
    ByRef source As UShort,   ' WORD* in/out
    sourceLen As Integer   ' INT
)
End Sub
' cnv : UConverter*
' source : WORD* in/out
' sourceLen : INT
Declare PtrSafe Sub ucnv_fixFileSeparator Lib "icuuc" ( _
    ByRef cnv As LongPtr, _
    ByRef source As Integer, _
    ByVal sourceLen As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ucnv_fixFileSeparator = ctypes.cdll.icuuc.ucnv_fixFileSeparator
ucnv_fixFileSeparator.restype = None
ucnv_fixFileSeparator.argtypes = [
    ctypes.c_void_p,  # cnv : UConverter*
    ctypes.POINTER(ctypes.c_ushort),  # source : WORD* in/out
    ctypes.c_int,  # sourceLen : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
ucnv_fixFileSeparator = Fiddle::Function.new(
  lib['ucnv_fixFileSeparator'],
  [
    Fiddle::TYPE_VOIDP,  # cnv : UConverter*
    Fiddle::TYPE_VOIDP,  # source : WORD* in/out
    Fiddle::TYPE_INT,  # sourceLen : INT
  ],
  Fiddle::TYPE_VOID, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn ucnv_fixFileSeparator(
        cnv: *const isize,  // UConverter*
        source: *mut u16,  // WORD* in/out
        sourceLen: i32  // INT
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void ucnv_fixFileSeparator(ref IntPtr cnv, ref ushort source, int sourceLen);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucnv_fixFileSeparator' -Namespace Win32 -PassThru
# $api::ucnv_fixFileSeparator(cnv, source, sourceLen)
#uselib "icuuc.dll"
#func global ucnv_fixFileSeparator "ucnv_fixFileSeparator" sptr, sptr, sptr
; ucnv_fixFileSeparator varptr(cnv), varptr(source), sourceLen
; cnv : UConverter* -> "sptr"
; source : WORD* in/out -> "sptr"
; sourceLen : INT -> "sptr"
出力引数:
#uselib "icuuc.dll"
#func global ucnv_fixFileSeparator "ucnv_fixFileSeparator" var, var, int
; ucnv_fixFileSeparator cnv, source, sourceLen
; cnv : UConverter* -> "var"
; source : WORD* in/out -> "var"
; sourceLen : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void ucnv_fixFileSeparator(UConverter* cnv, WORD* source, INT sourceLen)
#uselib "icuuc.dll"
#func global ucnv_fixFileSeparator "ucnv_fixFileSeparator" var, var, int
; ucnv_fixFileSeparator cnv, source, sourceLen
; cnv : UConverter* -> "var"
; source : WORD* in/out -> "var"
; sourceLen : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procucnv_fixFileSeparator = icuuc.NewProc("ucnv_fixFileSeparator")
)

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

typedef ucnv_fixFileSeparatorNative = Void Function(Pointer<IntPtr>, Pointer<Uint16>, Int32);
typedef ucnv_fixFileSeparatorDart = void Function(Pointer<IntPtr>, Pointer<Uint16>, int);
final ucnv_fixFileSeparator = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<ucnv_fixFileSeparatorNative, ucnv_fixFileSeparatorDart>('ucnv_fixFileSeparator');
// cnv : UConverter* -> Pointer<IntPtr>
// source : WORD* in/out -> Pointer<Uint16>
// sourceLen : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure ucnv_fixFileSeparator(
  cnv: Pointer;   // UConverter*
  source: Pointer;   // WORD* in/out
  sourceLen: Integer   // INT
); cdecl;
  external 'icuuc.dll' name 'ucnv_fixFileSeparator';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "ucnv_fixFileSeparator"
  c_ucnv_fixFileSeparator :: Ptr CIntPtr -> Ptr Word16 -> Int32 -> IO ()
-- cnv : UConverter* -> Ptr CIntPtr
-- source : WORD* in/out -> Ptr Word16
-- sourceLen : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ucnv_fixfileseparator =
  foreign "ucnv_fixFileSeparator"
    ((ptr intptr_t) @-> (ptr uint16_t) @-> int32_t @-> returning void)
(* cnv : UConverter* -> (ptr intptr_t) *)
(* source : WORD* in/out -> (ptr uint16_t) *)
(* sourceLen : 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 ("ucnv_fixFileSeparator" ucnv-fix-file-separator :convention :cdecl) :void
  (cnv :pointer)   ; UConverter*
  (source :pointer)   ; WORD* in/out
  (source-len :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ucnv_fixFileSeparator = Win32::API::More->new('icuuc',
    'void ucnv_fixFileSeparator(LPVOID cnv, LPVOID source, int sourceLen)');
# my $ret = $ucnv_fixFileSeparator->Call($cnv, $source, $sourceLen);
# cnv : UConverter* -> LPVOID
# source : WORD* in/out -> LPVOID
# sourceLen : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。