xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

StrToHex()

Converts a character string to a Hex string.

Syntax

StrToHex( <cString>, [<cSeparator>] ) --> cHexString

Arguments

<cString>
This is a character string to convert to hexadecimal notation.
<cSeparator>
Optionally, a character string can be specified that is inserted between the hexadecimal ASCII codes of each character in <cString>.

Return

The function returns a character string holding the passed value in hexadecimal notation.

Description

StrToHex() converts a character string to a Hex formatted character string by converting the ASCII codes of each charater in <cString> and collecting them in the return string. The reverse function is HexToStr() which accepts a Hex encoded character string.

Note:  <cSeparator> is provided for formatting purposes of the returned string and to enhance readability. If it is used, the returned string cannot be decoded with HexToStr().

Info

See also:CStr(), HexToNum(), HexToStr(), NumToHex(), Transform()
Category: Character functions , Conversion functions , xHarbour extensions
Source:rtl\hbhex2n.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates return values of StrToHex() without
// and with separating character

   PROCEDURE Main
      LOCAL cString := "xHarbour"

      ? StrToHex( cString )        // result: 78486172626F7572

      ? StrToHex( cString, "|" )   // result: 78|48|61|72|62|6F|75|72
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe