Integer to hexadecimal string

jicman cabrera_ at _wrc.xerox.com
Tue Mar 11 20:37:52 PDT 2008


jicman Wrote:

> Greetings!
> 
> I know this has probably been asked before, or there is a simple way to do this, but I can not find it.  I did a few searches on digitalmars on "decimal to hexadecimal" and got not hit.
> 
> So, here is my problem: I am using a COM object that uses a file with filenames on it and everything works fine until I have accented characters on the filenames, such as é, Ñ, ä, etc.  So, what I am trying to do is to change those filenames to URL style filename, such as,
> 
> c:\temp\my file\josé.doc
> 
> would change to,
> 
> c:\temp\my%20file\jos%e9.doc
> 
> So, I have two question:  Is there a function in phobos that does this automatically?  If not, how do I change an integer, say, 233 to hex, E9?
> 
> I know how to do this programmatically, but there is gotta be an easier way then me writing a function for this. :-)
> 
> thanks,
> 
> josé

Maybe I am going at this the wrong way...

Let me explain what the problem is:  I am using D to call a software that uses a Windows COM object to process a file which refers to a bunch of other files.  This file which this COM object uses as input I create using D.  This file is created by my doing a std.file.listdir(fd,"*") and then using those items returned from the listdir.  This works perfectly and I can create the file to pass to the COM object which uses the file paths referred in the created file and everything works.  However, when I have files with accented characters, I no longer have this working.  The COM application fails with "It can not find the path given..." and it gives the path, which interestingly enough, is broken exactly where the accented or extended character is.  I know what the problem is UTF8 vs. ANSI or one of those file kinds.  If I open the file I create, I can see the problem.  It is changing the file I created to ANSI, when it is really UTF8.  This COM object, since it is Windows (.NET to be exact) does not allow me to set the input file, so it wants something else than UTF8, which is what I am creating with D.  So, before I go and try to go through each of those filenames and rename then using URL base strings, is there something else that I can do to make this file be anything other than UTF8?

Thanks for the help.  Just point me to where to start reading... 

josé



More information about the Digitalmars-d-learn mailing list