I am reading a text file (attached) which contains the character '–' (i think ascii code 150, 0x96). The problem is, I can't seem to match/replace this character using preg_match / str_replace. When displaying the character, it comes up as a "?" (the character with ascii code 141 on here: http://www.idevelopment.info/data/Programming/ascii_table/PROGRAMMING_ascii_table.shtml
)
And the weird thing is, to try and see what the ascii code is (using count_chars) that php sees it as, returns 3 DIFFERENT values:
foreach (count_chars("–", 1) as $i => $val) {
$this->debug("", "i=$i There were $val instance(s) of ". chr($i) . " in the string. ord = " . ord(chr($i)) );
}
Outputs:
'i=128 There were 1 instance(s) of � in the string. ord = 128'
'i=147 There were 1 instance(s) of � in the string. ord = 147'
'i=226 There were 1 instance(s) of � in the string. ord = 226'
I think the problem might be in the way I'm reading the file contents (UTF-8 encoding by default for get_file_contents() ) ... Perhaps I need to read it as pure text so that the "–" character can stay preserved ? Only, not quite sure how to do a TEXT read using file / get_file_contents, the doc doesn't have example on this.
Help would be much appreciated,
Gerry