/** @return String a javascript literal string * WARNING: This implementation is NOT OK for UTF-8 and other multi byte charsets! * if you use those, you must override this method on StringConverter)*/ function toJsLiteral($string, $quote="'") { if ($string==null) return $quote.$quote; return $quote. str_replace( array('\\' , '<' , '>' , "\r" , "\n" , '"' ,"'" , '&' ), array("\\\\", "\\x3C" , "\\x3E" , "\\r", "\\n", "\\x22", "\\x27", "\\x26"), $string). $quote; } |