r""" Converts `val` so that it is safe for use in Unicode HTML. >>> websafe("<'&\">") u'<'&">' >>> websafe(None) u'' >>> websafe(u'\u203d') == u'\u203d' True
(val)
| 247 | |
| 248 | |
| 249 | def websafe(val): |
| 250 | r""" |
| 251 | Converts `val` so that it is safe for use in Unicode HTML. |
| 252 | |
| 253 | >>> websafe("<'&\">") |
| 254 | u'<'&">' |
| 255 | >>> websafe(None) |
| 256 | u'' |
| 257 | >>> websafe(u'\u203d') == u'\u203d' |
| 258 | True |
| 259 | """ |
| 260 | if val is None: |
| 261 | return "" |
| 262 | |
| 263 | if isinstance(val, bytes): |
| 264 | val = val.decode("utf-8") |
| 265 | elif not isinstance(val, str): |
| 266 | val = str(val) |
| 267 | |
| 268 | return htmlquote(val) |
| 269 | |
| 270 | |
| 271 | if __name__ == "__main__": |
no test coverage detected