KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is a translation of the below code at all possible using PHP? The code below is written in JavaScript. It returns html with numeric character references where needed. Ex. smslån -> smslån I have been unsuccessful at creating a translation. This script looked like it may work, but returns å for å instead of å as the javascript below does. function toEntity() { var aa = document.form.utf.value; var bb = ''; for(i=0; i<aa.length; i++) { if(aa.charCodeAt(i)>127) { bb += '&#' + aa.charCodeAt(i) + ';'; } else { bb += aa.charAt(i); } } document.form.entity.value = bb; } PHP's ord function sounds like it does the same thing as charCodeAt , but it does not. I get 195 for å using ord and 229 using charCodeAt. That, or I am having some incredibly difficult encoding problems.
Tags (comma-separated)
Save Edits
Cancel