How to code special characters... 
Author Message
 How to code special characters...

Hi,

Once more I am sorry to disturb you with a problem that may be simple to
go through...

Here is my problem:

I know that in C (sorry), there are 2 differents way to code special
characters like Carriage Return, Form Feed, Bell, BackSpace, Horizontal
Tab, etc.....

For example :
char c, d;
c = '\b';   /* backspace with C way */
d = '\x08'; /* backspace with hex # */

I already know that in Pascal I can do this:
c : char;
c := #8;    /* I think this is Dec # */

Is there some other ways to do this? for example some macro like \b ?
Can I do it in hexa?

Thank you
Cyrille



Wed, 18 Jun 1902 08:00:00 GMT  
 How to code special characters...
On Wed, 30 Sep 1998 10:53:49 -0700, Cyrille MAUCCI

Quote:

> I know that in C (sorry), there are 2 differents way to code special
> characters like Carriage Return, Form Feed, Bell, BackSpace, Horizontal
> Tab, etc.....

> For example :
> char c, d;
> c = '\b';   /* backspace with C way */
> d = '\x08'; /* backspace with hex # */

or  c=8  or  c=010  or   c=0x08

Quote:
> I already know that in Pascal I can do this:
> c : char;
> c := #8;    /* I think this is Dec # */

In C char is a numeric data type. It's like a small integer. In Pascal
it is not a numerical data type. The syntax for non-printable
characters in Borland Pascal is

        #val

where val is a decimal or hex literal constant

        #13  or #$d

It can be used as a part of a string

        'This is the first line'#13#10'and this is the second line'

The standard Pascal form is

        chr(value)

Regards
Horst



Wed, 18 Jun 1902 08:00:00 GMT  
 How to code special characters...
Just in case you didn't understand the first reply (seemed a bit confusing
to me), here's a simpler version of it:

In Pascal, if you want to declare a variable to have a certain value, then
yes, you need to specifically state that value.  Example: C = #8, C = #10, C
= #13, etc.  (BS, LF, CR)

If you want to use any character in a string, you can simply enter it into
the string, with the characters preceding and following the character to be
enclosed within single quotes.

Example: 'This string has a' #13#10 'CR/LR in the middle of it'

You can also use the + modifier to 'add' the character to a string (ex: 'ab'
+ #99 = 'abc')

Hope this helps.

Quote:

> Hi,

> Once more I am sorry to disturb you with a problem that may be simple to
> go through...

> Here is my problem:

> I know that in C (sorry), there are 2 differents way to code special
> characters like Carriage Return, Form Feed, Bell, BackSpace, Horizontal
> Tab, etc.....

> For example :
> char c, d;
> c = '\b';   /* backspace with C way */
> d = '\x08'; /* backspace with hex # */

> I already know that in Pascal I can do this:
> c : char;
> c := #8;    /* I think this is Dec # */

> Is there some other ways to do this? for example some macro like \b ?
> Can I do it in hexa?

> Thank you
> Cyrille



Wed, 18 Jun 1902 08:00:00 GMT  
 How to code special characters...


Quote:

>If you want to use any character in a string, you can simply enter it into
>the string, with the characters preceding and following the character to be
>enclosed within single quotes.

>Example: 'This string has a' #13#10 'CR/LR in the middle of it'

Incorrect. There cannot be any spaces (outside of the quotes) in the
string. It should be 'This string has a'#13#10'CR/LR in the middle of it'

Quote:

>You can also use the + modifier to 'add' the character to a string (ex: 'ab'
>+ #99 = 'abc')

This is a string concatenation operator. It is a different thing from
writing a single string constant.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 How to code special characters...

00:49:37 in comp.lang.pascal.borland, Osmo Ronkanen

Quote:

>>You can also use the + modifier to 'add' the character to a string (ex: 'ab'
>>+ #99 = 'abc')

>This is a string concatenation operator. It is a different thing from
>writing a single string constant.

A test on Turbo 7.01 showed concatenation occurring at compile time.

This makes "const S255 = <string of 255 characters> ;" effectively
possible; the characters cannot be written on a single line.

This was posted to too many newsgroups :
   comp.lang.pascal,comp.lang.pascal.misc,comp.lang.pascal.borland

c.l.p was rmgrouped long ago; and posting to both b & m is rarely
necessary.

--

  Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.



Wed, 18 Jun 1902 08:00:00 GMT  
 How to code special characters...
const Tab = #9; {or Char(9) or ^I}
        BkSp = #8; {or Char(8) or ^H}
        CR = #13; {or Char(13) or ^M}
        LF = #10; {or Char(10) or ^J}



Quote:
> Hi,

> Once more I am sorry to disturb you with a problem that may be simple to
> go through...

> Here is my problem:

> I know that in C (sorry), there are 2 differents way to code special
> characters like Carriage Return, Form Feed, Bell, BackSpace, Horizontal
> Tab, etc.....

> For example :
> char c, d;
> c = '\b';   /* backspace with C way */
> d = '\x08'; /* backspace with hex # */

> I already know that in Pascal I can do this:
> c : char;
> c := #8;    /* I think this is Dec # */

> Is there some other ways to do this? for example some macro like \b ?
> Can I do it in hexa?

> Thank you
> Cyrille



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How to code special characters...

2. Special character/language driver problems in BDE 4.nn and later

3. Special characters ( Swedish & Norwegian )

4. Query and special characters ??

5. Special characters vom Interbase 4.2 to Interbase 5.5

6. Processing text files with special characters

7. Tables with special characters in field names

8. Apollo updating Special characters

9. Which functions returns the ASCII code of a character

10. Character codes

11. ASCII character codes

12. converting string characters to char characters

 

 
Powered by phpBB® Forum Software