Print Page | Close Window

convert hex value to string

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: General Discussion
Forum Description: Topics Related to Visual C++ MFC Development in General
URL: http://forum.codejock.com/forum_posts.asp?TID=2113
Printed Date: 13 May 2024 at 10:03am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: convert hex value to string
Posted By: manoj
Subject: convert hex value to string
Date Posted: 14 April 2005 at 5:33am

hi

please tell me how can i convert hex value to normal charactor string programatically

e.g.
44,00,3a,00,5c,00,44,00,6f,00,63,00,75,00,6d,00,65,00,6e,00, 74,00,73,00,20,00,61,00,6e,00,64,00,20,00,53,00,65,00,74,00, 74,00,69,00,6e,00,67,00,73,00,5c,00,41,00,6d,00,6f,00,6c,00, 2e,00,41,00,4d,00,4f,00,4c,00,5c,00,4c,00,6f,00,63,00,61,00, 6c,00,20,00,53,00,65,00,74,00,74,00,69,00,6e,00,67,00,73,00, 5c,00,41,00,70,00,70,00,6c,00,69,00,63,00,61,00,74,00,69,00, 6f,00,6e,00,20,00,44,00,61,00,74,00,61,00,5c,00,4d,00,69,00, 63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,5c,00,4f,00,75,00, 74,00,6c,00,6f,00,6f,00,6b,00,5c,00,4f,00,75,00,74,00,6c,00, 6f,00,6f,00,6b,00,2e,00,70,00,73,00,74,00,00,00

want to convert in normal string pls send me pcs of code

 

Thanking you

 

Manoj Jangid




Replies:
Posted By: gshawn
Date Posted: 14 April 2005 at 5:55am

What language? Here is some VB code off the top of my head:

Dim strArray As String
Dim strLetters() As String
Dim strTranlation As String

strArray = "44,00,3a,00,5c,00,44,00,6f,00,63,00,75,00,6d,00,65,00,6e,00"

strLetters = Split(strArray, ",")

For i=lBound(strLetters) To uBound(strLetters)
    strTranslation = strTranslation & Chr(Val("&H" & strLetters(i)))
Next

MsgBox strTranslation

Looking at your string, it looks like it's UNICODE since every other byte is 00 so you'll probably want to handle that too... a simple Replace(1, strArray, ",00", "") might do the trick if you have no way to change the format of the hex character string.

Hope this helps!



Posted By: manoj
Date Posted: 14 April 2005 at 6:33am

I need a c++ code and in above code spaces is trucated if i use replace method.

 

Thanking you




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net