collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: problem with encoding again...  (Read 2015 times)

0 Members and 1 Guest are viewing this topic.

Offline Brianich

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
  • Kingpin Fixer
problem with encoding again...
« on: October 30, 2007, 06:11:18 pm »
Hello, i was out of ao for long time. now im totally back and trying to install latest bot. All working fine exept 1 thing, again... How to make cp1251 encoding work with new bot, last time i have resolved this problem with adding this code to bot.php, now it not working.

Quote
<?
function utf2win1251 ($s)
{
 $out = "";

 for ($i=0; $i<strlen($s); $i++)
 {
  $c1 = substr ($s, $i, 1);
  $byte1 = ord ($c1);
  if ($byte1>>5 == 6) // 110x xxxx, 110 prefix for 2 bytes unicode
  {
   $i++;
   $c2 = substr ($s, $i, 1);
   $byte2 = ord ($c2);
   $byte1 &= 31; // remove the 3 bit two bytes prefix
   $byte2 &= 63; // remove the 2 bit trailing byte prefix
   $byte2 |= (($byte1 & 3) << 6); // last 2 bits of c1 become first 2 of c2
   $byte1 >>= 2; // c1 shifts 2 to the right

   $word = ($byte1<<8) + $byte2;
   if ($word==1025) $out .= chr(168);                    // ?
   elseif ($word==1105) $out .= chr(184);                // ?
   elseif ($word>=0x0410 && $word<=0x044F) $out .= chr($word-848); // ?-? ?-?
   else
   {  
     $a = dechex($byte1);
     $a = str_pad($a, 2, "0", STR_PAD_LEFT);
     $b = dechex($byte2);
     $b = str_pad($b, 2, "0", STR_PAD_LEFT);
     $out .= "&#x".$a.$b.";";
   }
  }
  else
  {
   $out .= $c1;
  }
 }

 return $out;
}

function cp1251_utf8( $sInput )
{
   $sOutput = "";

   for ( $i = 0; $i < strlen( $sInput ); $i++ )
   {
       $iAscii = ord( $sInput[$i] );

       if ( $iAscii >= 192 && $iAscii <= 255 )
           $sOutput .=  "&#".( 1040 + ( $iAscii - 192 ) ).";";
       else if ( $iAscii == 168 )
           $sOutput .= "&#".( 1025 ).";";
       else if ( $iAscii == 184 )
           $sOutput .= "&#".( 1105 ).";";
       else
           $sOutput .= $sInput[$i];
   }
  
   return $sOutput;
}

Thanks.
Super "Fixbrian" Girl
RK1, Clan
Current project: No data avaible...

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: problem with encoding again...
« Reply #1 on: October 30, 2007, 11:17:14 pm »
I don't know if those functions work or even what they do, never played around with the charsets and encoding.

But just adding those functions alone won't do much good, you'll have to call them in the message handling functions, too. I think they need to be in inc_tell(), inc_pggmsg() and inc_gmsg() and the send_*() functions, in one way or another.

Check your old Bot.php for calls to the functions you have, the names of the functions haven't changed in Bot.php.

Offline Blueeagle

  • Omnipotent
  • BeBot Hero
  • ******
  • Posts: 323
  • Karma: +0/-0
Re: problem with encoding again...
« Reply #2 on: October 31, 2007, 03:30:55 am »
Are you looking for http://php.net/iconv perhaps?

Other than that I really, really do recomend upgrading your server to handle UTF-8.
The only problem that can't be solved by adding another wrapper is having too many wrappers.

Offline Brianich

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
  • Kingpin Fixer
Re: problem with encoding again...
« Reply #3 on: October 31, 2007, 12:34:02 pm »
Yeah im looking for iconv, but it not working too (Becouse im gimp in code), maybe someone can halp me to install it properly?
Super "Fixbrian" Girl
RK1, Clan
Current project: No data avaible...

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 687
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal