Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #10367

Re: Newline (cr/lf) in imagestring

From Lew Pitcher <lew.pitcher@digitalfreehold.ca>
Subject Re: Newline (cr/lf) in imagestring
Newsgroups comp.lang.php
References <46kqv8d4tqhl15ripkbc1dfjb2m0tqvgtt@4ax.com> <timstreater-A09450.22012803082013@news.individual.net> <zyeLt.331254$0a4.83683@fx06.iad> <timstreater-A7A0E7.22534603082013@news.individual.net>
Organization The Pitcher Digital Freehold
Message-ID <LMfLt.354599$aW2.188146@fx13.iad> (permalink)
Date 2013-08-03 18:47 -0400

Show all headers | View raw


On Saturday 03 August 2013 17:53, in comp.lang.php, timstreater@greenbee.net
wrote:

> In article <zyeLt.331254$0a4.83683@fx06.iad>,
>  Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
> 
>> On Saturday 03 August 2013 17:01, in comp.lang.php,
>> timstreater@greenbee.net wrote:
>> 
>> > In article <46kqv8d4tqhl15ripkbc1dfjb2m0tqvgtt@4ax.com>,
>> >  Ed Jay <edMbj@aes-intl.com> wrote:
>> > 
>> >> So...how do I produce cr/lf?
>> > 
>> > $lf = chr (10);
>> > $cr = chr (13);
>> > $nl = $cr . $lf;
>> 
>> Alternatively,
>> 
>>   $lf = chr (37);
>>   $cr = chr (13);
>>   $nl = $cr . $lf;
>> 
>> or even
>> 
>>   $nl = chr (21);
>> 
>> Control characters are very platform specific, don't you think?
>> 
>> > Simples.
>> 
>> Only if you restrict Ed's solution to the platform /you/ use.
> 
> The OP asked for CR and LF, which is what I gave. 21 is NAK and 37 is %,
> according to:
> 
> <http://www.asciitable.com>

He's using ASCII??

37 is Line Feed,
13 is Carriage Return, and
21 is New Line
in EBCDIC. And, PHP runs on EBCDIC machines.

Better to use '\r' for Carriage Return, and '\n' for Linefeed / Newline, or
PHP defined constant (iirc, $PHP_EOL), and let PHP decide which platform,
which characterset, and which codepoints to use.


Or, better still, use the proper function (in the OP's case, another call to
imagestring() ) to achieve the proper text alignment.

HTH
-- 
Lew Pitcher
"In Skills, We Trust"

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Newline (cr/lf) in imagestring Ed Jay <edMbj@aes-intl.com> - 2013-08-03 11:59 -0700
  Re: Newline (cr/lf) in imagestring Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2013-08-03 16:26 -0400
    Re: Newline (cr/lf) in imagestring Ed Jay <edMbj@aes-intl.com> - 2013-08-03 13:31 -0700
    Re: Newline (cr/lf) in imagestring The Natural Philosopher <tnp@invalid.invalid> - 2013-08-03 21:53 +0100
  Re: Newline (cr/lf) in imagestring Tim Streater <timstreater@greenbee.net> - 2013-08-03 22:01 +0100
    Re: Newline (cr/lf) in imagestring Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2013-08-03 17:24 -0400
      Re: Newline (cr/lf) in imagestring Tim Streater <timstreater@greenbee.net> - 2013-08-03 22:53 +0100
        Re: Newline (cr/lf) in imagestring Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2013-08-03 18:47 -0400
  Re: Newline (cr/lf) in imagestring Richard Damon <Richard@Damon-Family.org> - 2013-08-03 18:02 -0400
  Re: Newline (cr/lf) in imagestring Ed Jay <edMbj@aes-intl.com> - 2013-08-03 15:56 -0700
    Re: Newline (cr/lf) in imagestring The Natural Philosopher <tnp@invalid.invalid> - 2013-08-04 02:52 +0100

csiph-web