Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > ascii code for a tab?

Reply
Thread Tools

ascii code for a tab?

 
 
Ken Kafieh
Guest
Posts: n/a
 
      05-10-2004
does anyone know the ascii code for a tab?


 
Reply With Quote
 
 
 
 
Christophe Vanfleteren
Guest
Posts: n/a
 
      05-10-2004
Ken Kafieh wrote:

> does anyone know the ascii code for a tab?


If you need to print a tab:

System.out.println("This part goes before the \t, this part after it");

If you need the actual code: 9

--
Kind regards,
Christophe Vanfleteren
 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      05-10-2004
Ken Kafieh wrote:

> does anyone know the ascii code for a tab?


Have you tried looking it up in an ASCII table? You can only find about
a bazillion of them on the web. (Try
http://www.google.com/search?hl=en&i...=Google+Search)
Not to mention in the programmer's manuals of many compilers for many
languages. Or how about the empirical approach: even in Java, which
tends to be somewhat verbose when it comes to short programs, a console
program that would help you find the answer for yourself could be as
short as about a dozen lines. Any of those methods would have been
quicker than asking on Usenet.


John Bollinger
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      05-10-2004
On Mon, 10 May 2004 13:11:13 GMT, "Ken Kafieh"
<kkafieh-StopSp@(E-Mail Removed)> wrote or quoted :

>does anyone know the ascii code for a tab?


see http://mindprod.com/jgloss/ascii.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      05-10-2004
On Mon, 10 May 2004 13:17:08 GMT, Christophe Vanfleteren
<(E-Mail Removed)> wrote or quoted :

>System.out.println("This part goes before the \t, this part after it");


for more of those magic characters see
http://mindprod.com/jgloss/literals.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Ken Kafieh
Guest
Posts: n/a
 
      05-10-2004

> Have you tried looking it up in an ASCII table? You can only find about
> a bazillion of them on the web.


That didn't occur to me. It seems like a good idea now. But I never thought
of that as being something many people would necessarily display on the
Internet. There is so many more interesting things to put up. But now that
you mention it, it seems like better first step. I'll remember that for
next time.

> Not to mention in the programmer's manuals of many compilers for many
> languages.


I have no manual for the compiler or any compiler. I have no ascii tables at
my disposal. .

>Or how about the empirical approach: even in Java, which tends to be

somewhat verbose when it comes to short programs, a console program that
would help you find the answer for yourself could be as short as about a
dozen lines.

I thought about that. I have done it before. but the program did so many
white space characters that I wasn't sure which one of them was the tab.

> Any of those methods would have been quicker than asking on Usenet.


Thank you for helping me to improve my research skills. I am sorry for
bothering you.


 
Reply With Quote
 
Tony Morris
Guest
Posts: n/a
 
      05-10-2004
> > does anyone know the ascii code for a tab?
>
> If you need to print a tab:
>
> System.out.println("This part goes before the \t, this part after it");
>
> If you need the actual code: 9



Note that you are printing a Unicode character representation, not ASCII.
Equivalent to:
System.out.println('\u0009');

--
Tony Morris
(BInfTech, Cert 3 I.T.)
Software Engineer
(2003 VTR1000F)
Sun Certified Programmer for the Java 2 Platform (1.4)
Sun Certified Developer for the Java 2 Platform



 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      05-13-2004
Tony Morris wrote:
> Note that you are printing a Unicode character representation, not ASCII.
> Equivalent to:
> System.out.println('\u0009');


True, but perhaps a bit dangerous. It's sometimes important to know
that \uXXXX is a completely different construct in Java from \t. The
former is translated prior to lexical analysis, and is syntactically
significant; the latter form is interpreted after lexical and syntactic
analysis, and so can never affect the lexical structure or syntax of the
language.

For \t, this rarely matters except for the quibble that \t is only
allowed in a string literal, while \u0009 can occur anywhere in code.
However, try \u000A in a string literal and see what happens... or more
interestingly:

// This looks like \u000A it's all a comment, but it's not!

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      05-14-2004
On Thu, 13 May 2004 17:13:51 -0600, Chris Smith <(E-Mail Removed)>
wrote or quoted :

>> System.out.println('\u0009');

>
>True, but perhaps a bit dangerous.


it is treated exactly as if you had written
System.out.println (' ');
where you hit the tab character between the quotes.
Tab might work but NL would not. Because Java would look at that as:
System.out.println ('
');

Literals are not allowed to span lines.

You use \n.


--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Liz
Guest
Posts: n/a
 
      05-14-2004

"Chris Smith" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)4.net...
> Tony Morris wrote:
> > Note that you are printing a Unicode character representation, not

ASCII.
> > Equivalent to:
> > System.out.println('\u0009');

>
> True, but perhaps a bit dangerous. It's sometimes important to know
> that \uXXXX is a completely different construct in Java from \t. The
> former is translated prior to lexical analysis, and is syntactically
> significant; the latter form is interpreted after lexical and syntactic
> analysis, and so can never affect the lexical structure or syntax of the
> language.
>
> For \t, this rarely matters except for the quibble that \t is only
> allowed in a string literal, while \u0009 can occur anywhere in code.
> However, try \u000A in a string literal and see what happens... or more
> interestingly:
>
> // This looks like \u000A it's all a comment, but it's not!


Now that is good to know,
I never would have thought of it, tnx.

>
> --
> www.designacourse.com
> The Easiest Way to Train Anyone... Anywhere.
>
> Chris Smith - Lead Software Developer/Technical Trainer
> MindIQ Corporation



 
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
Regex with ASCII and non-ASCII chars TOXiC Python 5 01-31-2007 04:48 PM
How to convert an ascii code into a character? keithb ASP .Net 1 03-15-2006 05:52 PM
ASCII Code Andre ASP .Net 8 03-02-2006 09:56 PM
[FR/EN] how to convert the characters ASCII(0-255) to ASCII(0-127) Alextophi Perl Misc 8 12-30-2005 10:43 AM
routine/module to translate microsoft extended ascii to plain ascii James O'Brien Perl Misc 3 03-05-2004 04:33 PM



Advertisments