-
AuthorPosts
-
October 24, 2007 at 6:32 am #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 wordsThanks
rhand Friendrhand
- Join date:
- November 2006
- Posts:
- 213
- Downloads:
- 0
- Uploads:
- 2
- Thanks:
- 9
- Thanked:
- 15 times in 1 posts
October 26, 2007 at 5:40 am #231546It does? Never saw it. Please post link…
October 26, 2007 at 5:53 am #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 Friendstefiart
- Join date:
- June 2007
- Posts:
- 10
- Downloads:
- 0
- Uploads:
- 0
- Thanks:
- 2
- Thanked:
- 1 times in 1 posts
December 7, 2007 at 7:40 am #234087Dear 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
December 7, 2007 at 8:08 am #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
March 27, 2008 at 7:30 am #243322Where is the common.php located?
regards
March 27, 2008 at 7:47 am #243325/modules/ja_news
March 27, 2008 at 8:04 am #243328Thanks 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
-
AuthorPosts
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