Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Padding a string with hexadecimal values

Status
Not open for further replies.

huskers

Programmer
Jan 29, 2002
75
US
Can any one tell me how I can pad a string with hexadecimal values in Tcl. I am new to this area. A string str1 should look like this:
[hexadecimal 2]str1[hexadecimal 3]. This is done just to make sure that str1 can contain any value and when i am reading it i will know that it starts with hexadecimal 4 and ends with hexadecimal 3.

Thanks in advance
 
When you say "hexadecimal 3", do you mean a character whose ASCII code is 0x03? If so, then it's simply a matter of using the [tt]\x[/tt] backslash substitution:

Code:
set str1 "Test"
set str2 "\x3$str1\x4"

- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Yup that was what i was looking for....Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top