🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages Started by Amer Alhabsi Mon, 31 Mar 2003 16:54
Converting unicode hex digits
#17242
Author: Amer Alhabsi
Date: Mon, 31 Mar 2003 16:54
11 lines
1214 bytes
Hi,

I have a line, in a text file, that represent a folder name. It is, however,
in unicode and is given as hex digits. How can I read the folder name and
use it in functions like "OpenFile" or the OpenDialog box. The line looks
like:

hex(2):25,55,73,65,72,50,72,6f,66,69,6c,65,25,5c,4c,6f,63,61,6c,\
  20,53,65,74,74,69,6e ...

Thanks,
Re: Converting unicode hex digits
#17243
Author: Remy Lebeau (TeamB)
Date: Mon, 31 Mar 2003 17:24
12 lines
1398 bytes
"Amer Alhabsi" <alhabsiNOSPAM@squ.edu.om> wrote in message
news:3e8872e8@newsgroups.borland.com...

> I have a line, in a text file, that represent a folder name.

Is the file storing the actual binary values of each character, or just
string representations of the numericdigits?  That makes a big difference.
Can you post the actual file to the .attachments group for us to look at?


Gambit
Re: Converting unicode hex digits
#17244
Author: Amer Alhabsi
Date: Mon, 31 Mar 2003 19:00
40 lines
2534 bytes
"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3e887aae$1@newsgroups.borland.com...
> Is the file storing the actual binary values of each character, or just
> string representations of the numericdigits?  That makes a big difference.
> Can you post the actual file to the .attachments group for us to look at?

Below is excerpt of the file. The whole file can be recreated from the
command line by asking "regedit.exe" to export a key-hive as follows:
regedit /e:a ident.txt "HKEY_CURRENT_USER\identities"

This exports outlook express data into a text file. What I'm interested in
is the value of "store root" which represents the folder outlook express
stores data.

Thanks,

--------excerpt of file -------------------
[HKEY_CURRENT_USER\identities\{FA922CB2-FCF5-441C-ABB8-E699CB6984E3}\Softwar
e\Microsoft\Outlook Express\5.0]
"VerStamp"=dword:00000003
"SpellDontIgnoreDBCS"=dword:00000001
"MSIMN"=dword:00000001
"StoreMigratedV5"=dword:00000001
"ConvertedToDBX"=dword:00000001
"Settings Upgraded"=dword:00000007
"Running"=dword:00000001
"Store
Root"=hex(2):25,55,73,65,72,50,72,6f,66,69,6c,65,25,5c,4c,6f,63,61,6c,\

20,53,65,74,74,69,6e,67,73,5c,41,70,70,6c,69,63,61,74,69,6f,6e,20,44,61,74,\

61,5c,49,64,65,6e,74,69,74,69,65,73,5c,7b,46,41,39,32,32,43,42,32,2d,46,43,\

46,35,2d,34,34,31,43,2d,41,42,42,38,2d,45,36,39,39,43,42,36,39,38,34,45,33,\

7d,5c,4d,69,63,72,6f,73,6f,66,74,5c,4f,75,74,6c,6f,6f,6b,20,45,78,70,72,65,\
  73,73,5c,00
"PrevToolbarTextStyle"=dword:00000001
--------------- rest of file -------------
Re: Converting unicode hex digits
#17248
Author: Remy Lebeau (TeamB)
Date: Mon, 31 Mar 2003 20:09
52 lines
2870 bytes
"Amer Alhabsi" <alhabsiNOSPAM@squ.edu.om> wrote in message
news:3e88906b@newsgroups.borland.com...

> This exports outlook express data into a text file. What
> I'm interested in is the value of "store root" which represents
> the folder outlook express stores data.

What OS are you running under?  I assume WinNT/2K/XP?  On my Win98 machine,
the "Store Root" value is a simple ASCII string:

    "Store Root"="F:\\Program Files\\Internet Mail and News\\Gambit"

For what you're asking, you'll have to manually parse the string into its
individual digits, and then you can use StrToInt() to convert the strnigs in
actual numeric values and then cast them to wchar_t as needed.  For example
(untested; error handling ommited for simplicity):

    AnsiString asStoreRoot = extract "Store Root" value from file;
    WideString wStoreRoot;

    if( asStoreRoot.SubString(1, 3) != "hex" )
        wStoreRoot = asStoreRoot;
    else
    {
        // remove "hex" prefix...
        int pos = asStoreRoot.Pos(":");
        if( pos != 0 ) asStoreRoot.Delete(1, pos);

        // strip off "\", spaces, and line breaks...
        TReplaceFlags flags = TReplaceFlags() << rfReplaceAll
        asStoreRoot = StringReplace(asStoreRoot, "\\", "", flags);
        asStoreRoot = StringReplace(asStoreRoot, "\r\n", "", flags);
        asStoreRoot = StringReplace(asStoreRoot, " ", "", flags);

        // tokenize the digits...
        TStringList *digits = new TStringList;
        digits->CommaText = asStoreRoot.Trim();
        wStoreRoot.SetLength(digits->Count);

        // convert the digits...
        for(int x = 0; x < digits->Count; x++)
            wStoreRoot[x] = (wchar_t) StrToInt("0x" + digits->Strings[x]);

        // cleanup
        delete digits;
    }

    // use wStoreRoot as needed...


Gambit
Re: Converting unicode hex digits
#17252
Author: Amer Alhabsi
Date: Mon, 31 Mar 2003 22:35
17 lines
1654 bytes
"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3e88a08e$1@newsgroups.borland.com...
>
> For what you're asking, you'll have to manually parse the string into its
> individual digits, and then you can use StrToInt() to convert the strnigs
in
> actual numeric values and then cast them to wchar_t as needed.  For
example
> (untested; error handling ommited for simplicity):
>
>     AnsiString asStoreRoot = extract "Store Root" value from file;
>     WideString wStoreRoot;

Thank you very much. The solution is very helpful. Thanks again.

Amer,
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads