prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Unicode content in rich text causes error
  Steps to reproduce:
  1. Using the wagtail interface, create a new instance of a page derived model which has a rich text field
  2. In the rich text field, include unicode characters such as: `©`  or `’`
  3. Publish the page
     
     The page will be published fine, and probably rendered normally through a template.
  4. Return to the wagtail admin, and edit the newly created page
     
     The rich text field is not rendered in the editing page. Inspecting the html shows that wagtail is attempting to render the field, its heading is there. But the field is not rendered.
     
     If you attempt to publish this new page, the form will submit a page with no content in the rich text field.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `wagtail/utils/widgets.py`
  Content:
  ```
  1 from django.forms.widgets import Widget
  2 from django.utils.safestring import mark_safe
  3 
  4 
  5 class WidgetWithScript(Widget):
  6     def render(self, name, value, attrs=None):
  7         widget = super(WidgetWithScript, self).render(name, value, attrs)
  8 
  9         final_attrs = self.build_attrs(attrs, name=name)
  10         id_ = final_attrs.get('id', None)
  11         if 'id_' is None:
  12             return widget
  13 
  14         js = self.render_js_init(id_, name, value)
  15         out = '{0}<script>{1}</script>'.format(widget, js)
  16         return mark_safe(out)
  17 
  18     def render_js_init(self, id_, name, value):
  19         return ''
  20
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/wagtail/utils/widgets.py b/wagtail/utils/widgets.py
  --- a/wagtail/utils/widgets.py
  +++ b/wagtail/utils/widgets.py
  @@ -1,3 +1,5 @@
  +from __future__ import absolute_import, unicode_literals
  +
   from django.forms.widgets import Widget
   from django.utils.safestring import mark_safe
   
  @@ -8,7 +10,7 @@
   
           final_attrs = self.build_attrs(attrs, name=name)
           id_ = final_attrs.get('id', None)
  -        if 'id_' is None:
  +        if id_ is None:
               return widget
   
           js = self.render_js_init(id_, name, value)
  
verification_info: {"golden_diff": "diff --git a/wagtail/utils/widgets.py b/wagtail/utils/widgets.py\n--- a/wagtail/utils/widgets.py\n+++ b/wagtail/utils/widgets.py\n@@ -1,3 +1,5 @@\n+from __future__ import absolute_import, unicode_literals\n+\n from django.forms.widgets import Widget\n from django.utils.safestring import mark_safe\n \n@@ -8,7 +10,7 @@\n \n         final_attrs = self.build_attrs(attrs, name=name)\n         id_ = final_attrs.get('id', None)\n-        if 'id_' is None:\n+        if id_ is None:\n             return widget\n \n         js = self.render_js_init(id_, name, value)\n", "issue": "Unicode content in rich text causes error\nSteps to reproduce:\n1. Using the wagtail interface, create a new instance of a page derived model which has a rich text field\n2. In the rich text field, include unicode characters such as: `\u00a9`  or `\u2019`\n3. Publish the page\n   \n   The page will be published fine, and probably rendered normally through a template.\n4. Return to the wagtail admin, and edit the newly created page\n   \n   The rich text field is not rendered in the editing page. Inspecting the html shows that wagtail is attempting to render the field, its heading is there. But the field is not rendered.\n   \n   If you attempt to publish this new page, the form will submit a page with no content in the rich text field.\n\n", "before_files": [{"content": "from django.forms.widgets import Widget\nfrom django.utils.safestring import mark_safe\n\n\nclass WidgetWithScript(Widget):\n    def render(self, name, value, attrs=None):\n        widget = super(WidgetWithScript, self).render(name, value, attrs)\n\n        final_attrs = self.build_attrs(attrs, name=name)\n        id_ = final_attrs.get('id', None)\n        if 'id_' is None:\n            return widget\n\n        js = self.render_js_init(id_, name, value)\n        out = '{0}<script>{1}</script>'.format(widget, js)\n        return mark_safe(out)\n\n    def render_js_init(self, id_, name, value):\n        return ''\n", "path": "wagtail/utils/widgets.py"}], "after_files": [{"content": "from __future__ import absolute_import, unicode_literals\n\nfrom django.forms.widgets import Widget\nfrom django.utils.safestring import mark_safe\n\n\nclass WidgetWithScript(Widget):\n    def render(self, name, value, attrs=None):\n        widget = super(WidgetWithScript, self).render(name, value, attrs)\n\n        final_attrs = self.build_attrs(attrs, name=name)\n        id_ = final_attrs.get('id', None)\n        if id_ is None:\n            return widget\n\n        js = self.render_js_init(id_, name, value)\n        out = '{0}<script>{1}</script>'.format(widget, js)\n        return mark_safe(out)\n\n    def render_js_init(self, id_, name, value):\n        return ''\n", "path": "wagtail/utils/widgets.py"}]}