I have a form that accepts file uploads. A user is free to upload files with any names they like. Most file names will be in English, but some will have names with East Asian characters (Chinese, Korean, etc.)
I need to save these files to a Windows server. And I must keep their original names.
Is it necessary for Perl to know the language of the string? Is it possible to "sniff out" the language?
Thanks for any ideas on how to implement this. ikegami has already provided much help with this code:
use strict;
use warnings;
use Encode qw( encode );
use Symbol qw( gensym );
use Win32API::File qw(
CreateFileW
OsFHandleOpen
CREATE_ALWAYS
GENERIC_WRITE
);
my $qfn = chr(0x263a); # Whatever
my $win32f = CreateFileW(
encode('UCS-2le', $qfn),
GENERIC_WRITE, # For writing
0, # Not shared
[], # Security attributes
CREATE_ALWAYS, # Create and replace
0, # Special flags
[], # Permission template
)
or die("CreateFile: $^E\n");
OsFHandleOpen( my $fh = gensym(), $win32f, 'w' )
or die("OsFHandleOpen: $^E\n");
print $fh "Foo!\n";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.