LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert the string "\n" to the newline character

Does anyone know of a quick and elegant way to convert ASCII strings in the form of "\<some character>" to the corresponding byte value. For example, if I have the string "\n" I would like to convert it to the byte value of 0x0A. I realize I could brute force it with a case structure or a lookup table but I need to do this for all of the various escape character sequences. So far I haven't come up with a simple solution.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 1 of 4
(4,957 Views)

Look into vi.lib \Advanced String\ and peek at "Escape String.vi"

 

While it would be nicer if "Escapes" had an appropriate default value you at least get a frame to start from.  

\vi.lib\Utility\config.llb also contains both an escape and unescape string function that are a bit more user friendly

 

 

 

 


"Should be" isn't "Is" -Jay
Message 2 of 4
(4,928 Views)

@JÞB wrote:

Look into vi.lib \Advanced String\ and peek at "Escape String.vi"

 

 


This works but besides saving a bit of effort creating the lookup this does put me back to the case where I need to add all of teh various escape characters choices. As you mentioned, it would have been really nice if they had those set as the default.

 

Thanks.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 4
(4,918 Views)

@Mark_Yedinak wrote:

@JÞB wrote:

Look into vi.lib \Advanced String\ and peek at "Escape String.vi"

 

 


This works but besides saving a bit of effort creating the lookup this does put me back to the case where I need to add all of teh various escape characters choices. As you mentioned, it would have been really nice if they had those set as the default.

 

Thanks.


That is why I also pointed out \vi.lib\Utility\config.llb\ Escape String.vi and Unescape String.vi.  They are a bit rough on the eyes but better than re-inventing the wheel.

 

 

Spoiler
You really don't NEED to open the BDsSmiley Wink

 

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 4
(4,902 Views)