I've built a MySQL database for a client and a web interface to be able to
add/edit/delete records in it. When he's adding stuff to the database he's
copying text from MS Word. I've tried various substitutions that I've found
hanging around the internet, but nothing's working for the "long dash" that
it insists on converting normal hyphens to.
This morning I did a bin2hex to see exactly what was being sent from $_POST:
A - long dash -.
41 20 >>>e2 80 93<<< 20 6c 6f 6e 67 20 64 61 73 68 20 2d 2e 20 20
The offending character is the one I've highlighted. As far as I can tell,
it should be getting found by this -
"\\xe2\\x80\\x9 3", // long dash
but it isn't, which makes me think there's something wrong with the code
I've copied. How to find the hex string? I've tried "\xe2\x80\x 93" and
"\xe2x80x93 " in addition, but to no avail.
Is driving me scatty!!!
Any help much appreciated.
$search = array( chr(145),
chr(146),
chr(147),
chr(148),
chr(151),
chr(196),
'â?o', // left side double smart quote
'â?', // right side double smart quote
'â?~', // left side single smart quote
'â?T', // right side single smart quote
'â?¦', // elipsis
'â?"', // em dash
'â?"', // en dash
"\\xe2\\x80\\xa 6", // ellipsis
"\\xe2\\x80\\x9 3", // long dash
"\\xe2\\x80\\x9 4", // long dash
"\\xe2\\x80\\x9 c", // double quote opening
"\\xe2\\x80\\x9 d", // double quote closing
"\\xe2\\x80\\xa 2" // dot used for bullet points
);
$replace = array( "'",
"'",
'"',
'"',
'-',
'-',
'"',
'"',
"'",
"'",
"…",
"-",
"-",
'…',
'-',
'-',
'"',
'"',
'*'
);
ECHO '<p>'.BIN2HEX( $_POST['short_desc'] ).'</p>';
$short_desc = STR_REPLACE($se arch, $replace, $_POST['short_desc']);
+mrcakey
add/edit/delete records in it. When he's adding stuff to the database he's
copying text from MS Word. I've tried various substitutions that I've found
hanging around the internet, but nothing's working for the "long dash" that
it insists on converting normal hyphens to.
This morning I did a bin2hex to see exactly what was being sent from $_POST:
A - long dash -.
41 20 >>>e2 80 93<<< 20 6c 6f 6e 67 20 64 61 73 68 20 2d 2e 20 20
The offending character is the one I've highlighted. As far as I can tell,
it should be getting found by this -
"\\xe2\\x80\\x9 3", // long dash
but it isn't, which makes me think there's something wrong with the code
I've copied. How to find the hex string? I've tried "\xe2\x80\x 93" and
"\xe2x80x93 " in addition, but to no avail.
Is driving me scatty!!!
Any help much appreciated.
$search = array( chr(145),
chr(146),
chr(147),
chr(148),
chr(151),
chr(196),
'â?o', // left side double smart quote
'â?', // right side double smart quote
'â?~', // left side single smart quote
'â?T', // right side single smart quote
'â?¦', // elipsis
'â?"', // em dash
'â?"', // en dash
"\\xe2\\x80\\xa 6", // ellipsis
"\\xe2\\x80\\x9 3", // long dash
"\\xe2\\x80\\x9 4", // long dash
"\\xe2\\x80\\x9 c", // double quote opening
"\\xe2\\x80\\x9 d", // double quote closing
"\\xe2\\x80\\xa 2" // dot used for bullet points
);
$replace = array( "'",
"'",
'"',
'"',
'-',
'-',
'"',
'"',
"'",
"'",
"…",
"-",
"-",
'…',
'-',
'-',
'"',
'"',
'*'
);
ECHO '<p>'.BIN2HEX( $_POST['short_desc'] ).'</p>';
$short_desc = STR_REPLACE($se arch, $replace, $_POST['short_desc']);
+mrcakey
Comment