Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > dump the real string

Reply
Thread Tools

dump the real string

 
 
gnari
Guest
Posts: n/a
 
      02-26-2004
"toylet" <toylet_at_mail.hongkong.com> wrote in message
news:(E-Mail Removed)-cable.com...
> Tad McClellan wrote:
> >>> printf ".%02x.\n", ord foreach (split //, $line);
> >> can I also use split(/\b/,$line)?

> > What happened when you tried it?

>
> it worked as well. SO it's the default separator used by split()?


read the docs before asking things like this
perldoc -f split

it is not so much a default separator, as a special case
of the function split with no arguments, that has an
extra funtionality.

gnari




 
Reply With Quote
 
 
 
 
gnari
Guest
Posts: n/a
 
      02-26-2004
"toylet" <toylet_at_mail.hongkong.com> wrote in message
news:403d79e7$(E-Mail Removed)-cable.com...
> > Maybe that a text in Chinese with 20 characters typically requires 40

bytes
> > to be stored?
> > So what to you want to know? The length of the string in characters or

the
> > size of the allocated memory. You were asking for the memory size.

>
> I didn't expect my question on displaying the bytes in a string would
> end up talking about multi-lingual isssues.


it was just that someone corrected you whan you implied that length()
would give the number of bytes, which is only valid for some
encodings/systems. the thread only went on because you protested.

gnari




 
Reply With Quote
 
 
 
 
Andrew McGregor
Guest
Posts: n/a
 
      02-26-2004

"toylet" <toylet_at_mail.hongkong.com> wrote in message
news:(E-Mail Removed)-cable.com...
> >> my $line = <>;
> >>
> >> I input "a" and press enter.
> >>
> >> Now $line should contain 2 bytes: 'a' and end-of-line character.
> >>
> >> How could I print the content of $line (both bytes) in hex format?

> > perldoc -f substr
> > perldoc -f hex

>
> hex() should not be relevant as I need to convert from numeric to hex
> digits. Already knew about substr().
>


Then why use a none numeric example, 'a'?


 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      02-26-2004
toylet wrote:

> You meant length() would react to unicode settings in Perl?


Yes. UTF-8 encoding uses 8, 16, 24 or 32 bits per character.

>> It is important to stop thinking of characters as matching C's char
>> type, and to stop thinking of C's char type always being 8 bits (even
>> though a char is always a byte).

>
> I think one byte always equal to 8 bits. All computer courses taught
> that. 9-bit byte? What machines do that?


Three of the first five computers connected to the ARPANET were
36-bit computers. They used 7-bit ASCII for regular text,
SIXBIT for COBOL data, strings of 5-bit codes for FORTRAN error
messages. When talking to other computers, the PDP-10 used
8-bit bytes, 9-bit bytes, 12-bit bytes, 16-bit bytes and 18-bit bytes.

A byte is defined to be a contiguous set of bits. When talking
about 8-bit bytes, the proper term is "octet".

-Joe http://www.inwap.com/pdp10/
 
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
Dump complete java VM state as core dump (not via OS) possible? halfdog Java 12 02-21-2013 06:14 AM
OT: The Interview - Real, Funny...Real Funny The Rev [MCT] MCSE 42 05-31-2005 10:42 PM
call any usa REAL telephone number from the internet at pulver freeworld for .06 per minute - have your own real fone # for $10 month!! ucallvoip@yahoo.com VOIP 0 06-09-2004 01:41 AM
product of real and (integer)(after converted to real one) value - vhdl found fatal error senthil VHDL 5 01-24-2004 04:37 AM
data conversion question (binary string to 'real string') Alexander Eisenhuth Python 5 07-25-2003 06:42 PM



Advertisments