Geshi a utf-8

0

Witam. Mam kodowanie strony utf-8 (boom) i geshi. Wykonuje:

$geshi =& new GeSHi(html_entity_decode($zmiennazkodem, "php");
$geshi->set_encoding("utf-8"); //choc jak to usune to jest to samo :(
$geshi->parse_code();

Jeszcze w pliku geshi.php $encoding ustawilem na utf-8 . Gdy dostaje wynik, to dostaje gratis znaki zapytania, cos w stylu np:

<?php
 if (file_exists('test'))
????? readfile('test);
??? else echo('test');
?> a powinno być
<?php
 if (file_exists('test'))
          readfile('test');
     else echo('test');
?>

Ymm robiłem już funkcją iconv:
iconv("ISO-8859-1","UTF-8",$geshi->parse_code()); . Usuneły się znaki zapytania, lecz znów polskie znaki zamieniły sie w krzaczki.. Jak tu rozwiązać ten problem?
PS.
Zmieniłem tez kodowanie geshi.php na utf-8 i tez nie dziala

0

ymm daje wynik ja bez iconv. to znaczy polskie znaki, ale gratis pytajniki

0

Zawsze możesz podejrzeć Coyote - też używa GeSHi + UTF-8

0

juz to robilem, wlasnie z tego wiem ze mam zmienic encoding na utf-8. I jeszcze kodowanie pliku geshi na utf-8 (jesli tego nie zrobilem mialem 3 dziwne znaki).
Ale już wiem gdzie jest ,,error"i. O to kod:

<?php
include_once('geshi.php');
$source = '&lt;php&gt;<br />&lt;?php<br />&nbsp;if (file_exists(\'liczniki/pliczek.exe.txt\'))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; readfile(\'liczniki/pliczek.exe.txt\');<br />&nbsp;&nbsp;&nbsp;&nbsp; else echo(\'0\');//jeśli brak ściągnięć to dajemy na 0<br />?&gt;&lt;/php&gt;';
function nowewersy($phpz)
{
$phpz=str_replace('<br />',chr(13),$phpz);
return $phpz;
}
$pattern = '/&lt;php&gt;(.+?)&lt;\/php&gt;/s';
function koloruj($in){
$geshi =& new GeSHi(nowewersy(html_entity_decode($in[1])), 'php');
  return $geshi->parse_code();
}
echo preg_replace_callback($pattern, 'koloruj', $source);



?>

// He, he, skąd ja pamiętam tę funkcję :) - Cold

Jak wykonacie to gratis dostaniecie ????? (zapytajniki). Chodziło o 1 rzecz html_entity_decode. ona jest dla iso. Wiec zamieniłem ta funkcje na

function html_entity_decode_utf8($string)
{
    static $trans_tbl;
   
    // replace numeric entities
    $string = preg_replace('~&#x([0-9a-f]+);~ei', 'code2utf(hexdec("\\1"))', $string);
    $string = preg_replace('~&#([0-9]+);~e', 'code2utf(\\1)', $string);

    // replace literal entities
    if (!isset($trans_tbl))
    {
        $trans_tbl = array();
       
        foreach (get_html_translation_table(HTML_ENTITIES) as $val=>$key)
            $trans_tbl[$key] = utf8_encode($val);
    }
   
    return strtr($string, $trans_tbl);
}

// Returns the utf string corresponding to the unicode value (from php.net, courtesy - [email protected])
function code2utf($num)
{
    if ($num < 128) return chr($num);
    if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
    if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
    if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
    return '';
}

1 rzecz 5 godzin w plecy :9
Więc mozna usunąć temat - lub pozostawic potomnych

1 użytkowników online, w tym zalogowanych: 0, gości: 1