try to save a UTF file name

I have a website that allows users to upload files. Some of those files may contain special characters, such as chinese or japanese characters in the file name. While my upload piece works fine, I call a DLL that was written in VB6 that does some processing of the file (saves meta data to the database).

my problem lies in trying to read these files with special characters in them. I haven't been able to find a way to encode these characters, the only thing I can find online is to encode entire files by creating a memory stream and encoding the bytes as the go into memory, then write it to a file. What I want to do is simply encode the file name so I can access it and its path in my VB6 dll.
LVL 34
Big MontyWeb Ninja at largeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

any file with the extended characters has a 8.3 mapping, i.e. your "C:\Program Files" folder is also accessible as "C:\progra~1". There are different ways of getting the 8.3 filename. One of the easiest is to use a GetShortPathName API:
Option Explicit

Private Declare Function GetShortPathName Lib "kernel32" _ 
   Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
   ByVal lpszShortPath As String, ByVal cchBuffer As Long) _
   As Long
Public Function ShortPath(ByVal strFilename As String) As String
    Dim strBuffer As String * 255
    Dim lngReturnCode As Long
    Dim iFileNumber As Integer
    iFileNumber = FreeFile
    If Dir(strFilename) = "" Then
        On Error Resume Next
        Open strFilename For Output As #iFileNumber
        Close #iFileNumber
    End If
    lngReturnCode = GetShortPathName(strFilename, strBuffer, 255)
    ShortPath = Left$(strBuffer, lngReturnCode)
End Function

Open in new window

And here is an example from MSDN
Dave BaldwinFixer of ProblemsCommented:
This page says...
On newer file systems, such as NTFS, exFAT, UDFS, and FAT32, Windows stores the long file names on disk in Unicode, which means that the original long file name is always preserved. This is true even if a long file name contains extended characters, regardless of the code page that is active during a disk read or write operation.
This page however says Windows uses UTF-16 encoding.
Big MontyWeb Ninja at largeAuthor Commented:
i don't think I explained myself well enough...

i have the file already uploaded on to the server. This is done via my web app. after the upload, my dll is called to do some basic processing of the file, and the file name (including the path) is passed as a parameter to the function in the dll i'm calling. one of the processing steps is to move the file to it's final location. the path that's being passed into the function contains japanese characters, which is causing the move functionality to bomb because it cannot read those characters. is there a way, in VB6, to get around that?
Rename the file in the web app straight after upload and before passing it to the dll. Replace the utf characters with some Latin equivalents

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big MontyWeb Ninja at largeAuthor Commented:
renaming the file before passing it to the DLL is the method I'm going to take. Although this was decided before your comment, I'll award the points for the different ideas.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.