Forum Moderators: coopster

Message Too Old, No Replies

Setting special characters within array

         

toplisek

7:25 am on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have array for alphabetical values to set icons like:

foreach(range('A','Z') as $i) {
array_push($myarr_1, $i);
}

How to set also other characters for other languages like:

¹èæ¾ð

This is non-english characters set.

enigma1

8:52 am on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could use the integer equivalent of various characters with chr(). You could also use a translation tale if you don't want to store the foreign characters for example:

$translation_table = array(
chr(0) => '0',
chr(1) => '1',
);

toplisek

9:25 am on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm new to this. Can you send me sample on my characters ¹èæ¾ð with my code
foreach(range('A','Z') as $i) {
array_push($myarr_1, $i);
}

enigma1

9:45 am on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$string = chr(232) . chr(230) . chr(190) . chr(240);
echo $string;

and with your code:

foreach(range('A','Z') as $i) {
array_push($myarr_1, $i);
}
// Include individual foreign characters
array_push($myarr_1, chr(232), chr(230), chr(190), chr(240));

You use the integers as it's easier with the text editors.

toplisek

10:45 am on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm not sure but it does not recognise valid character:
array_push($myarr_1, chr(138), 'È', 'Æ', chr(142), 'Ð');

How to set with raw content like I used'È'

it shows me ,?'

Description of this:
[gtwiki.org...]

and manual PHP at URL:

Returns a one-character string containing the character specified by ascii.

[php.net...]

If I understand this means demand for ASCII encoding on UTF-8 pages. Special characters will not work in this way.

Is this correct?

enigma1

11:04 am on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yes that's what it does, it returns the one-character string. chr(198) is for 'Æ' Why don't you use the integers and which special character won't work? The representation is with integers to get around it and will work for all characters.

toplisek

11:47 am on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have used chr(138) but it does not show ©.
It pushes ? not ©
As mentioned pages are stored as UTF-8.

enigma1

11:55 am on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



© is chr(169)

Where the pages are stored? Or the array that holds these characters? Storage is another matter.

toplisek

12:10 pm on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Smarty based array.
1. What do you mean Where the pages are stored?
2.Or the array that holds these characters?
Storage is another matter. ...?

there is string utf8_encode ( string $data )
This function encodes the string data to UTF-8, and returns the encoded version. UTF-8 is a standard mechanism used by Unicode for encoding wide character values into a byte stream. UTF-8 is transparent to plain ASCII characters, is self-synchronized (meaning it is possible for a program to figure out where in the bytestream characters start)

Can be done by this? How would be solved in my example?
If I use 169 it will be the same published ,?'

enigma1

12:16 pm on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As mentioned pages are stored as UTF-8

Stored where? you mean output to the browser or you store them in the database or in a file etc.

How do you get the question marks? It usually means the medium you use either cannot display them or is setup incorrectly. So if you're using some text editor make sure is setup for UTF8 and can support UTF8. And database storage requires configuration for UTF8.

toplisek

12:57 pm on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



All encoding is set to UTF-8 and works. Pages are not in the database. I use correct editor. You are probably correct:
it usually means the medium you use either cannot display them or is setup incorrectly.

I have tested jgrid. Maybe it does not support this special characters.

enigma1

1:07 pm on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try notepad++ is open source from sourceforge.net there is a setting in menu->encoding to switch to utf8 (without BOM).

toplisek

1:17 pm on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, I have. All is stored as UTF8 (without BOM)