pythongosssss / ComfyUI-Custom-Scripts

Enhancements & experiments for ComfyUI, mostly focusing on UI features
MIT License
1.87k stars 144 forks source link

Bug: SaveText UnicodeEncodeError #380

Open EnragedAntelope opened 4 weeks ago

EnragedAntelope commented 4 weeks ago

Hi, When I have a nonstandard character within the text that I am trying to save, I receive an error. Can this be addressed?

In this case it was "Zdzisław Beksiński" if you need an example. Below is the error I received. Thank you!

2024-10-28 13:58:53,847 - root - ERROR - !!! Exception during processing !!! 'charmap' codec can't encode character '\u0142' in position 205: character maps to <undefined>
2024-10-28 13:58:53,863 - root - ERROR - Traceback (most recent call last):
  File "D:\ComfyUI\execution.py", line 323, in execute
    output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\execution.py", line 198, in get_output_data
    return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\execution.py", line 169, in _map_node_over_list
    process_inputs(input_dict, i)
  File "D:\ComfyUI\execution.py", line 158, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\text_files.py", line 187, in write_text
    f.write(kwargs["text"])
  File "C:\Users\Default.LivingRoomPC\.pyenv\pyenv-win\versions\3.11.9\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u0142' in position 205: character maps to <undefined>