Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Are Strings automatically null terminated?

Reply
Thread Tools

Are Strings automatically null terminated?

 
 
Thomas Schodt
Guest
Posts: n/a
 
      07-10-2008
Arne Vajhøj wrote:
> Mark Space wrote:
>> I don't think \0 is a legal character representation in Java. Did you
>> try it? It should give an illegal escape sequence error. (I didn't
>> try it either, however.) \u0 I think is the null character.

>
> I believe Java insist on \u0000.


Unicode translation is done before lexical analysis
and you get a literal ASCII NUL in the String at compile time.

Causes problems if we were talking about LF or CR.
http://bugs.sun.com/bugdatabase/view...bug_id=4209933

For characters in the control character range
prefer the octal escape sequence "\000" through "\37"
over the unicode encoding "\u0000" through "\u001f".

Well, I do anyway.
 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      07-13-2008
Thomas Schodt wrote:
> Arne Vajhøj wrote:
>> Mark Space wrote:
>>> I don't think \0 is a legal character representation in Java. Did
>>> you try it? It should give an illegal escape sequence error. (I
>>> didn't try it either, however.) \u0 I think is the null character.

>>
>> I believe Java insist on \u0000.

>
> Unicode translation is done before lexical analysis
> and you get a literal ASCII NUL in the String at compile time.
>
> Causes problems if we were talking about LF or CR.
> http://bugs.sun.com/bugdatabase/view...bug_id=4209933
>
> For characters in the control character range
> prefer the octal escape sequence "\000" through "\37"
> over the unicode encoding "\u0000" through "\u001f".
>
> Well, I do anyway.


I would use \r and \n for CR and LF.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
automatically initialized to null? bob smith Java 8 08-10-2012 03:53 PM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
Why compilers do not "p = NULL" automatically after programs do "delete p"? gary C++ 13 11-05-2005 12:27 AM
RAILS: edit turns null strings into empty strings Wybo Dekker Ruby 1 07-23-2005 05:30 PM



Advertisments