php-general Digest 19 Dec 2011 08:43:58 -0000 Issue 7616

Topics (messages 316061 through 316062):

Re: Preferred Syntax
        316061 by: Robert Cummings

Re: Converting a Unicode code to related charachter
        316062 by: Ali Asghar Toraby Parizy

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 11-12-17 09:42 AM, Eric Butera wrote:
Hi Adam,

Thanks for the reply, noted!  I was coming from the angle that I've
had to deal with a lot of code that is 2000 lines of
php/html/javascript inside heredocs, mixed quote escaping, etc.  I was
hoping to prevent that from becoming a new thing in this persons code
if that was the case.  Apologies for assuming.

I understand that point of view, but your overarching statement of using full separation of presentation and logic at all times is wrong in the general case. Sometimes a 10 line script of mixed logic and presentation is just what the doctor ordered... but that might happen more often when doing small concise command-line scripts :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
Thanks for your reply. But the function that I've written, converts a code
to a character. for example if input is u0631 the output will be: ARABIC
LETTER REH "ر"
But I think that use of this json_decode() is a little nonsense! I didn't
find a straightforward function to do this ,though I've searched a lot.

On Mon, Dec 19, 2011 at 11:51 AM, Francisco M. Marzoa Alonso <
franci...@marzoa.com> wrote:

> Hello,
>
> Can you please provide an example of real input and the output expected?
>
> I'm not sure about what you want to do. Anyway, for converting utf-8
> characters into plain ASCII "equivalents" chars, you can use iconv
> "translit" feature like:
>
> $rtn = iconv ('UTF-8', 'ASCII//TRANSLIT', $string);
>
> You may need to set locale before using setlocale. For Spanish strings I
> use this code:
>
> setlocale (LC_ALL, 'es_ES.UTF-8');
> $rtn = iconv ('UTF-8', 'ASCII//TRANSLIT', $string);
>
> If I use for example this as $string:
>
> 'ביםףתס'
>
> I will get this as $rtn at return:
>
> 'aeioun'
>
> Regards,
>
>
>
>
>
> On 18/12/11 10:33, Ali Asghar Toraby Parizy wrote:
> > Hi.
> > As I was writing a php code last week, I struggled with a function that
> was
> > supposed to convert Unicode code to a character. At last I wrote this
> > function:
> >
> > function unicodeToChr($param) {
> >
> >         $a =json_decode('{"t":"'.$param.'"}');
> >
> >         return $a->t;
> > }
> >
> >
> > In this function the $param should be something like '\u0627'. I want to
> > know if it's acceptable to use this function? Does exist any better
> > solution to do that?
> > Thanks.
> >
>
>

--- End Message ---

Reply via email to