-2

I am parsing a string like any other string, or apparently it is I am still getting instead of some white spaces the parser is working with all other strings but this

the original string is :

CONTENT content CONTENT content CONTENT content CONTENT 

I am getting :

CONTENT content�CONTENT content�CONTENT content�

I did filter the output from /r/n /n and HTML characters , and as I mentioned , it works with every other string and html characters

do you have any reasons for that ? I tried to encode the output , but nothing changed , but when I decode it , it disappears along with all the string

code :

    $posts_info[$counter][2] = preg_replace("/&#?[a-z0-9]{2,8};/i","",$posts_info[$counter][2]);
    $posts_info[$counter][2] = str_replace(array("\r\n", "\r"), "\n", $posts_info[$counter][2]);
    $n_lines = explode("\n",   $posts_info[$counter][2]);
    $new_lines = array();

    foreach ($n_lines as $i => $line) {
        if(!empty($line))
            $new_lines[] = trim($line);
    }

    $posts_info[$counter][2] =    implode($new_lines);
Leonid Shevtsov
  • 14,024
  • 9
  • 51
  • 82
Mike s
  • 119
  • 2
  • 13
  • What are you viewing the text with? A document editor, command line, web browser, etc? What are you using to parse the strings? – Mr. Llama Mar 16 '15 at 15:59
  • what language you parsing with? – cyadvert Mar 16 '15 at 16:00
  • I am using PHP , and viewing the text with Chrome , I will add the code that filters the output now , please note that I didn't have to add filters before I face this problem with that string – Mike s Mar 16 '15 at 16:04
  • What is your document encoding type/charset? – ʰᵈˑ Mar 16 '15 at 16:15

1 Answers1

0

After you connect to the database add the following command:

SET NAMES 'utf8';

Ensure that your web page also uses the UTF-8 encoding

Also check this link, it might be useful.. data from database is not inserted into my webpage properly

Community
  • 1
  • 1
Choxx
  • 945
  • 1
  • 24
  • 46