bartekd Posted December 14, 2012 Share Posted December 14, 2012 I am doing something with an API in another software, and I need to get the source of a html file and put it in a PHP file. I have everything working as intended, but I keep coming accross characters that PHP doesn't like, and it stops there. Is there some script I can use to catch all the characters that PHP doesn't like? This is part of how I am doing it now, and I keep adding this same line every time I come accross a character that makes the script stop. FYI $sHTML is the source code of the page. $sHTML = StringReplace($sHTML, '"', "'") $sHTML = StringReplace($sHTML, '“', "'") $sHTML = StringReplace($sHTML, '’', "'") $sHTML = StringReplace($sHTML, '”', "'") $sHTML = StringReplace($sHTML, 'à', "a") $sHTML = StringReplace($sHTML, 'â', "a") $sHTML = StringReplace($sHTML, 'ä', "a") $sHTML = StringReplace($sHTML, 'è', "e") $sHTML = StringReplace($sHTML, 'ê', "e") $sHTML = StringReplace($sHTML, 'é', "e") $sHTML = StringReplace($sHTML, 'ë', "e") $sHTML = StringReplace($sHTML, 'î', "i") Link to comment Share on other sites More sharing options...
FireFox Posted December 14, 2012 Share Posted December 14, 2012 (edited) Or... StringRegExpReplace($sData, '[^²&"''\(-\)=°\+~\\#\{\[\|`\^@\]\}$\*\?,:!\.%/\w]', "") Which replaces special letters/non latin languages. Br, FireFox. Edited December 14, 2012 by FireFox Link to comment Share on other sites More sharing options...
bartekd Posted December 14, 2012 Author Share Posted December 14, 2012 (edited) Doesn't seem to work for me. I still see letters like é etc... Do I need to format it differently before using that? $IEFile = "c:test" Local $oIE = _IECreate($IEFile & ".htm") Local $sHTML = _IEDocReadHTML($oIE) _IEQuit($oIE) StringRegExpReplace($sHTML, '[^²&"''(-)=°+~#{[|`^@]}$*?,:!.%w]', "") Edited December 14, 2012 by bartekd Link to comment Share on other sites More sharing options...
bartekd Posted December 14, 2012 Author Share Posted December 14, 2012 Nevermind, I forgot to put "$sHTML = "before your code. That doesn't seem to work because it takes out the important characters of the source (like the slashes etc). Any other ideas? Link to comment Share on other sites More sharing options...
FireFox Posted December 14, 2012 Share Posted December 14, 2012 That doesn't seem to work because it takes out the important characters of the source (like the slashes etc). Any other ideas?It's so hard to add a slash to the pattern.... edited my post. Link to comment Share on other sites More sharing options...
bartekd Posted December 14, 2012 Author Share Posted December 14, 2012 OK Thanks Firefox Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now