gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 line
706B

  1. ##########################################################################
  2. #
  3. # pgAdmin 4 - PostgreSQL Tools
  4. #
  5. # Copyright (C) 2013 - 2020, The pgAdmin Development Team
  6. # This software is released under the PostgreSQL Licence
  7. #
  8. #########################################################################
  9. """Utilities for HTML"""
  10. from html import escape as html_escape
  11. def safe_str(x):
  12. try:
  13. # For Python3, it can be int, float
  14. if isinstance(x, (int, float)):
  15. x = str(x)
  16. x = x.encode(
  17. 'ascii', 'xmlcharrefreplace'
  18. ) if hasattr(x, 'encode') else x
  19. x = x.decode('utf-8')
  20. except Exception:
  21. pass
  22. return html_escape(x, False)
上海开阖软件有限公司 沪ICP备12045867号-1