Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • Strats Friend
    #123386

    Those of us who us UTF, we have a problem, the last character of each article appears as “?”
    Is there any possible way to change the following setting:
    max Chars
    to
    max words

    Thanks

    rhand Friend
    #231546

    It does? Never saw it. Please post link…

    Strats Friend
    #231550

    <em>@rhand 30397 wrote:</em><blockquote>It does? Never saw it. Please post link…</blockquote>

    The problem is cause when the last letter is more than 1bit and because of the way the mbstring manipulate the UTF-8. There is a way of fixing this by changing the substr to substr_utf8 at the common.php and of course to add the extra function at the mod_janews.php

    So my question is in order to avoid all the above, is there any possible way to change the max Chars to max words?

    Thanks

    stefiart Friend
    #234087

    Dear Sir,
    I have the same problem and i don’t know about the “extra function at the mod_janews.php
    ” could you please explain more??

    Thanks

    Strats Friend
    #234090

    <em>@stefiart 33818 wrote:</em><blockquote>Dear Sir,
    I have the same problem and i don’t know about the “extra function at the mod_janews.php
    ” could you please explain more??

    Thanks</blockquote>

    Add the following code at the end of the mod_janews.php (right before tha last ?>). Then edit your common.php and change the substr to substr_utf8 (line 45).

    function substr_utf8( $string, $start, $length=0 ) {
    $s = preg_replace("/\&\#([0-9]{3,10})\;/e", '_html_to_utf8("\1")', $string);
    $pattern =
    '/^(
    [x09x0Ax0Dx20-x7E] # ASCII
    | [xC2-xDF][x80-xBF] # non-overlong 2-byte
    | xE0[xA0-xBF][x80-xBF] # excluding overlongs
    | [xE1-xECxEExEF][x80-xBF]{2} # straight 3-byte
    | xED[x80-x9F][x80-xBF] # excluding surrogates
    | xF0[x90-xBF][x80-xBF]{2} # planes 1-3
    | [xF1-xF3][x80-xBF]{3} # planes 4-15
    | xF4[x80-x8F][x80-xBF]{2} # plane 16
    )/x';
    while ( $start-- ) { getChr( $pattern, $s ); }
    if ( $length ) {
    $ret = '';
    while ( $length-- ) { $ret .= getChr( $pattern, $s ); }
    return $ret;
    }
    else { return $s; }
    }
    function getChr( $pattern, &$s ) {
    if ( preg_match( $pattern, $s, $match ) ) {
    $ret = $match[0];
    $p = "/^" . quotemeta( $match[0] ) . "/";
    $s = preg_replace( $p, '', $s );
    }
    else {
    $ret = substr( $s, 0, 1 );
    $s = substr( $s, 1 );
    }
    return $ret;
    }
    function _html_to_utf8 ($data) {
    if ($data > 127)
    {
    $i = 5;
    while (($i--) > 0)
    {
    if ($data != ($a = $data % ($p = pow(64, $i))))
    {
    $ret = chr(base_convert(str_pad(str_repeat(1, $i + 1), 8, "0"), 2, 10) + (($data - $a) / $p));
    for ($i; $i > 0; $i--)
    $ret .= chr(128 + ((($data % pow(64, $i)) - ($data % ($p = pow(64, $i - 1)))) / $p));
    break;
    }
    }
    }
    else
    $ret = "&#$data;";
    return $ret;
    }

    Credit goes to Efthimis Mavrogeorgiadis

    aram Friend
    #243322

    Where is the common.php located?

    regards

    Strats Friend
    #243325

    /modules/ja_news

    aram Friend
    #243328

    Thanks dear !

    I my JA_news folder i have not got any file like that , I have changed the code in mod_janews.php , but the common.php is not in the JA_News , I done a total search in all other folders as well , nothing , anywhere…

    Am using teline 4 joomla 1.5

    advice please

Viewing 8 posts - 1 through 8 (of 8 total)

This topic contains 8 replies, has 4 voices, and was last updated by  aram 16 years, 8 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum