LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-24-2009, 09:36 AM   #1
edomingox
Member
 
Registered: Mar 2009
Posts: 64

Rep: Reputation: 16
Escaping a variable in Groovy to show the ascii character in println?


I'm trying to display all the ascii characters using the following code in Groovy:

Code:
def x = 0
while (x++ < 255)
{
   println "$x=\$x"
}
output:
Code:
1=$x 2=$x 3=$x 4=$x 5=$x 6=$x 7=$x 8=$x 9=$x 10=$x
I would like to escape the variable that way I don't have to write out this:

Code:
println "1=\01"
println "2=\02"
println "3=\03"
println "4=\04"
println "5=\05"
...
is there a way to make this work?

This is the output I would like:

Code:
1= 2= 3= 4= 5=
 
Old 04-25-2009, 07:24 PM   #2
headrift
Member
 
Registered: Sep 2005
Distribution: Gentoo, Sabayon, Puppy, Arch
Posts: 165

Rep: Reputation: 29
I don't know Groovy, but it sounds like you need an eval() statement in there.

Of course, it looks to be Java, so you could try calling toString() and seeing if that helps. *shrug*

Hope that gets you in the right direction.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic special character escaping in Bash scripts? wipe Linux - Software 1 06-05-2009 06:41 PM
To know the function on checking whether a character is ascii or unicode character. murugesan Programming 2 01-23-2009 01:07 PM
Escaping spaces in a variable Ransak Programming 3 02-10-2008 01:54 AM
escaping ':' character in bash script paulyche Linux - General 2 11-07-2006 07:18 AM
perl post character escaping kapilcool Programming 3 12-20-2005 07:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration