Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding UTF-8 #3

Open
skom27 opened this issue Mar 9, 2023 · 5 comments
Open

encoding UTF-8 #3

skom27 opened this issue Mar 9, 2023 · 5 comments

Comments

@skom27
Copy link

skom27 commented Mar 9, 2023

Thank you for a great tool :) Unfortunately, I have a problem with merging two xml files. Unfortunately, the files contain characters encoded in UTF-8, where the script stops with an error

e.g. line: Украина 24 HD
or the pound sign in the description: "... for her £19,000 budget...." or "4 O'Clock Club" or "Sealladh ùr bho Alba". How can I solve this problem? (PS. I'm unfamiliar with python :( )

@foxhunt72
Copy link
Owner

send me two files that you want to merge, and i will see if i can fix it

with regards

richard

@skom27
Copy link
Author

skom27 commented Mar 9, 2023

Thank you for your willingness to help :) I just don't know how to send xml files?

@skom27
Copy link
Author

skom27 commented Mar 9, 2023

Mayby this way:
http://skom.pl/UK.xml
http://skom.pl/pl.xml

@foxhunt72
Copy link
Owner

foxhunt72 commented Mar 12, 2023 via email

@skom27
Copy link
Author

skom27 commented Mar 13, 2023

c:\Download\epg_grab>fhs-xmltv-tools join-xml-files --xmltv-file pl.xml --xmltv-file-add UK.xml --xmltv-out out.xml
fhs-xmltv-tools: 0.1.14
┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐
│ C:\Users\Krzysiek\AppData\Local\Programs\Python\Python311\Lib\site-packages\fhs_xmltv_tools\cli. │
│ py:251 in join_xml_files                                                                         │
│                                                                                                  │
│   248 │   │   data = join_programs(data, data02)                                                 │
│   249 │                                                                                          │
│   250 │   with console.status("Saving...", spinner="dots"):                                      │
│ > 251 │   │   xmltv_save(xmltv_out, data)                                                        │
│   252                                                                                            │
│   253                                                                                            │
│   254 @main.command()                                                                            │
│                                                                                                  │
│ C:\Users\Krzysiek\AppData\Local\Programs\Python\Python311\Lib\site-packages\fhs_xmltv_tools\xmlt │
│ v_load_save.py:32 in xmltv_save                                                                  │
│                                                                                                  │
│   29 │   │   xmltv_data: data object with xmltv data.                                            │
│   30 │   """                                                                                     │
│   31 │   xmltv_out = pathlib.Path(xmltv_file)                                                    │
│ > 32 │   xmltv_helpers.write_file_from_xml(xmltv_out, xmltv_data)                                │
│   33                                                                                             │
│   34                                                                                             │
│   35 def xmltv_empty(source_data_url="", source_info_name="", source_info_url=""):               │
│                                                                                                  │
│ C:\Users\Krzysiek\AppData\Local\Programs\Python\Python311\Lib\site-packages\xmltv\xmltv_helpers. │
│ py:70 in write_file_from_xml                                                                     │
│                                                                                                  │
│   67 │   │   no_namespace_schema_location=None))                                                 │
│   68 │                                                                                           │
│   69 │   with xml_file_path.open("w") as data:                                                   │
│ > 70 │   │   serializer.write(data, serialize_clazz)                                             │
│   71                                                                                             │
│                                                                                                  │
│ C:\Users\Krzysiek\AppData\Local\Programs\Python\Python311\Lib\site-packages\xsdata\formats\datac │
│ lass\serializers\xml.py:75 in write                                                              │
│                                                                                                  │
│    72 │   │   │   output=out,                                                                    │
│    73 │   │   │   ns_map=namespaces.clean_prefixes(ns_map) if ns_map else {},                    │
│    74 │   │   )                                                                                  │
│ >  75 │   │   handler.write(events)                                                              │
│    76 │                                                                                          │
│    77 │   def write_object(self, obj: Any):                                                      │
│    78 │   │   """Produce an events stream from a dataclass or a derived element."""              │
│                                                                                                  │
│ C:\Users\Krzysiek\AppData\Local\Programs\Python\Python311\Lib\site-packages\xsdata\formats\datac │
│ lass\serializers\mixins.py:117 in write                                                          │
│                                                                                                  │
│   114 │   │   │   elif event == XmlWriterEvent.ATTR:                                             │
│   115 │   │   │   │   self.add_attribute(*args)                                                  │
│   116 │   │   │   elif event == XmlWriterEvent.DATA:                                             │
│ > 117 │   │   │   │   self.set_data(*args)                                                       │
│   118 │   │   │   else:                                                                          │
│   119 │   │   │   │   raise XmlWriterError(f"Unhandled event: `{event}`")                        │
│   120                                                                                            │
│                                                                                                  │
│ C:\Users\Krzysiek\AppData\Local\Programs\Python\Python311\Lib\site-packages\xsdata\formats\datac │
│ lass\serializers\mixins.py:201 in set_data                                                       │
│                                                                                                  │
│   198 │   │                                                                                      │
│   199 │   │   if value:                                                                          │
│   200 │   │   │   if not self.in_tail:                                                           │
│ > 201 │   │   │   │   self.handler.characters(value)                                             │
│   202 │   │   │   else:                                                                          │
│   203 │   │   │   │   self.tail = value                                                          │
│   204                                                                                            │
│                                                                                                  │
│ C:\Users\Krzysiek\AppData\Local\Programs\Python\Python311\Lib\xml\sax\saxutils.py:213 in         │
│ characters                                                                                       │
│                                                                                                  │
│   210 │   │   │   self._finish_pending_start_element()                                           │
│   211 │   │   │   if not isinstance(content, str):                                               │
│   212 │   │   │   │   content = str(content, self._encoding)                                     │
│ > 213 │   │   │   self._write(escape(content))                                                   │
│   214 │                                                                                          │
│   215 │   def ignorableWhitespace(self, content):                                                │
│   216 │   │   if content:                                                                        │
│                                                                                                  │
│ C:\Users\Krzysiek\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1250.py:19 in encode   │
│                                                                                                  │
│    16                                                                                            │
│    17 class IncrementalEncoder(codecs.IncrementalEncoder):                                       │
│    18 │   def encode(self, input, final=False):                                                  │
│ >  19 │   │   return codecs.charmap_encode(input,self.errors,encoding_table)[0]                  │
│    20                                                                                            │
│    21 class IncrementalDecoder(codecs.IncrementalDecoder):                                       │
│    22 │   def decode(self, input, final=False):                                                  │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-6: character maps to <undefined>

With regards Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants