Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ASCII value for Empty String.

 
vaibhav kumbhar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was searching for ascii value of an empty string, ie "". I also wrote a small class for printing the ascii using character array but it gave me nothing. Does an empty string have an ascii value??
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Characters have ASCII values, not strings. And an empty string has no characters.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good suggestion by matthew.

you can refer this website http://ascii-table.com/ for your ASCII values search.

Ideally if you map it to an empty character, you would be placing a space character, which we ideally tend to interpret / mean that as an empty string. In that case, it is decimal 32. You can click on a particular character in the home page of the website where in you can see the relevant details on the right side.

See this sample program.



The output what you get is

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raghavan Muthu wrote:
Ideally if you map it to an empty character, you would be placing a space character, which we ideally tend to interpret / mean that as an empty string. In that case, it is decimal 32.


Bad advice. There's no such thing as an "empty character", and equating an empty String with any character just muddies the water. An empty String, by definition, has NO characters. There's no reason to say that NO characters is equivalent to SOME PARTICULAR character.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with you Jeff. It was a mistake. Thanks for pointing out.
 
vaibhav kumbhar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks All... so the bottom line is only character has an ascii value and since an empty string has no character it doesn't have any ascii value....
 
Stephan van Hulst
Bartender
Posts: 6327
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. The bottom line is that Strings have no ASCII value *at all*, empty or not.

It's a bit like saying that a song has a pitch. Songs don't have a pitch. The tones they are composed of have a pitch.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote: The bottom line is that Strings have no ASCII value *at all*, empty or not.

Confusion Friend Stephan.. I think I have to read some books on this...
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Confusion Friend Stephan.. I think I have to read some books on this...


A character has an ASCII value. A String (which may contain zero, one, or more characters) does not.

For example, what do you think would be the ASCII value of the String "Go placidly amidst the noise and waste, and remember what comfort there may be in owning a piece thereof. Avoid quiet and passive persons, unless you are in need of sleep. Rotate your tires"?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
42?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic