{
  "id": "python/sqlalchemy-unicode-encode-error",
  "signature": "UnicodeEncodeError: 'ascii' codec can't encode character '\\u2019' in position 10: ordinal not in range(128)",
  "signature_zh": "UnicodeEncodeError：'ascii' 编解码器无法编码位置 10 处的字符 '\\u2019'：序数不在 128 范围内",
  "regex": "UnicodeEncodeError:\\ 'ascii'\\ codec\\ can't\\ encode\\ character\\ '\\\\u2019'\\ in\\ position\\ 10:\\ ordinal\\ not\\ in\\ range\\(128\\)",
  "domain": "python",
  "category": "encoding_error",
  "subcategory": null,
  "root_cause": "Python 2 or misconfigured Python 3 environment trying to encode non-ASCII characters.",
  "root_cause_type": "generic",
  "root_cause_zh": "Python 2 或配置错误的 Python 3 环境尝试编码非 ASCII 字符。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Replacing characters with ASCII equivalents manually.",
      "why_fails": "Not scalable; data loss.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting sys.setdefaultencoding('utf-8') in Python 2.",
      "why_fails": "Deprecated and may cause side effects.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure database connection uses UTF-8.",
      "success_rate": 0.95,
      "how": "engine = create_engine('postgresql://user:pass@localhost/dbname?client_encoding=utf8')",
      "condition": "",
      "sources": []
    },
    {
      "action": "Encode strings to UTF-8 before storing.",
      "success_rate": 0.9,
      "how": "name = 'José'.encode('utf-8').decode('utf-8')  # Ensure proper encoding",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-05-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}