Google Answers Logo
View Question
 
Q: Convert hex string to UTF-16 string with Perl ( No Answer,   0 Comments )
Question  
Subject: Convert hex string to UTF-16 string with Perl
Category: Computers > Programming
Asked by: mrbananagrabber-ga
List Price: $10.00
Posted: 08 Jul 2006 13:56 PDT
Expires: 26 Jul 2006 07:55 PDT
Question ID: 744440
I am working on a Perl program that processes a Windows Registry .reg
file and outputs it into some defined XML. I have a problem
specificially with converting REG_MULTI_SZ to readable strings
(REG_MULTI_SZ are discussed here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/registry_reference.asp).

From a .reg file I have something like this:

"SystemBiosVersion"=hex(7):41,00,20,00,4d,00,20,00,49,00,20,00,20,00,2d,00,20,\
  00,39,00,30,00,30,00,30,00,32,00,31,00,30,00,00,00,42,00,49,00,4f,00,53,00,\
  20,00,44,00,61,00,74,00,65,00,3a,00,20,00,30,00,39,00,2f,00,31,00,30,00,2f,\
  00,30,00,32,00,20,00,30,00,39,00,3a,00,31,00,35,00,3a,00,31,00,32,00,20,00,\
  20,00,56,00,65,00,72,00,3a,00,20,00,30,00,38,00,2e,00,30,00,30,00,2e,00,30,\
  00,30,00,00,00,42,00,49,00,4f,00,53,00,20,00,44,00,61,00,74,00,65,00,3a,00,\
  20,00,30,00,39,00,2f,00,31,00,30,00,2f,00,30,00,32,00,20,00,30,00,39,00,3a,\
  00,31,00,35,00,3a,00,31,00,32,00,20,00,20,00,56,00,65,00,72,00,3a,00,20,00,\
  30,00,38,00,2e,00,30,00,30,00,2e,00,30,00,30,00,00,00,00,00
 
I can strip out the commas and backslashes and make one long hex
string. It should decode to a string that looks something like this
(regedit can be a little buggy sometimes):

"A M I  - 9000210\0BIOS Date: 09/10/02 09:15:12  Ver: 08.00.00\0BIOS
Date: 09/10/02 09:15:12  Ver: 08.00.00\0\0"

So I have 3 strings and each one ends with a null terminator and the
entire string ends with an extra null terminator.

The main issue I am having is that Perl's default encoding is UTF-8
and I am mostly certain that the string is a UTF-16 string.

What I need is Perl code that can convert a long hex multi-string like
above (without the commas and backslashes) into a readable UTF-16
string. Thanks.

Clarification of Question by mrbananagrabber-ga on 08 Jul 2006 13:59 PDT
To clarify, I want to have an array of strings from the multi-string
at the end. I need to know what each segment is and keep them apart. I
don't want to lose information.

Clarification of Question by mrbananagrabber-ga on 08 Jul 2006 15:13 PDT
Also, I'd prefer not to use any packages that don't come with Perl
since I don't know how to use CPAN or anything like that. But if
that's the only way, tell me and I'll figure out how to get the
package on my own.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy