-2

I have the following php code that I need to run on linux:

$BannedList = array
(
  'рублей'=> 'i'
);

foreach ( $BannedList as $BannedWord => $Option )
  if ( preg_match ( '#\\b'. preg_quote( $BannedWord, '#' ). '\\b#'. $Option,
                    $message_parser -> message )
     )
  {
    $error[]= ' ';
    break;
  }

The problem I am having is I have no idea how to use vi to enter the russian charcaters. Secondly, even if I have a way to type the russian characters, the php file is just a normal ascii file and incapable of holding the russian characters. So, how can I create a file containing this code ? Additionally, if I end up using a utf-8 file format, do I have to tell the php interpreter that this file is different to all the other ascii files it is running ?

Slava Vedenin
  • 58,326
  • 13
  • 40
  • 59
user118708
  • 197
  • 1
  • 13
  • You can use google translate and then copy from it and paste into vi. There is no need to change anything about the PHP file, simply paste the characters into it (but you will have to add a proper HTTP header https://www.w3.org/International/articles/http-charset/index). – DYZ Mar 17 '17 at 02:11
  • Google Translate is no use. I need to match the string in russian. – user118708 Mar 17 '17 at 02:12
  • Google translate has a virtual Russian keyboard that you can use to enter your text. – DYZ Mar 17 '17 at 02:13
  • This keyboard will enter russian in vi ? Well, it's easier if I just copy and past into vi. But the vi file is ascii and not capable of holding russian characters. – user118708 Mar 17 '17 at 02:17
  • That's what I said: copy from google translate and paste into vi. What do you mean by 'vi file is ascii '? Did you try to paste a UTF-8 character into it? – DYZ Mar 17 '17 at 02:18
  • Yes I paste into it and it gave me square blocks on screen. Then the code doesn't work as intended. – user118708 Mar 17 '17 at 02:20
  • Do you have Cyrillic fonts installed? – DYZ Mar 17 '17 at 02:21
  • I am using standard centos 7 install via ssh. I doubt Cyrillic is installed. If not installed, does that mean php won't understand the russian characters ? – user118708 Mar 17 '17 at 02:24
  • It means you won't see it. – DYZ Mar 17 '17 at 02:30
  • Why don't you just use UTF-8 as your charset across the platform? Seems like the better solution. – Qirel Mar 17 '17 at 02:38
  • I don't mind not seeing it as long as it is correctly in the file. As a test I pasted those characters into a file and did "od -x" on it. I get 80d1 83d1 b1d0 bbd0 b5d0 b9d0 000a. if I specify the string in code as '\x80\xd1\x83\xd1\xb1\xd0\xbb\xd0\xb5\xd0\xb9\xd0', the code does not appear to work. – user118708 Mar 17 '17 at 02:39
  • @Qirel because I am using phpBB. There are lots of files as given. I rather not change them all if they already work. – user118708 Mar 17 '17 at 02:40

1 Answers1

0

Took hours of random thrashing before finally arriving at the solution. The russian charcacters could be specified using unicode:

$BannedList = array
(
  '\x{0440}\x{0443}\x{0431}\x{043B}\x{0435}\x{0439}' => 'iu'
);
user118708
  • 197
  • 1
  • 13