Jump to content


Huevos

Member Since 14 Feb 2012
Offline Last Active Today, 01:35
*****

Posts I've Made

In Topic: How well is GigaBlue UHD UE 4K Cable supported?

Yesterday, 19:21

would you know of any other way to  have only one DVB-Input and watch one TV channel and in parallel record any 2 other channels? 

You can do that on any multi tuner box using a unicable LNB. Even the original duo could do that, watch one, record one, using unicable. Lots of second hand boxes around with 3 and 4 tuners.


In Topic: RC 9.0 - Problems with Windows filenames that contain Umlauts

2 March 2024 - 23:32

In post #105

The typemap is there to make sure the resulting string is utf-8 encoded

Maybe I didn't understand what you were asking, but it is not what the typemap is for.


In Topic: RC 9.0 - Problems with Windows filenames that contain Umlauts

2 March 2024 - 18:41

The answer is no. The type map is not to ensure that the input is correct utf8.

In Topic: RC 9.0 - Problems with Windows filenames that contain Umlauts

2 March 2024 - 15:45

I have no clue what you're on about. The typemap is implemented in eServiceReference, which has nothing to do with eBackgroundFileEraser ?

 

I don't need to be lectured about strings, bytes, encode() and decode(), I know what they do and how they work.

 

And I made a point of the fact I understand the need to preserve the original path because that is needed for all I/O operations (which include delete), and the fact that surrogateescape does that.

Just like eBackgroundFileEraser the typemap in eServiceReference follows exactly the same reasoning... and I am not lecturing anyone... you asked how it works.


In Topic: RC 9.0 - Problems with Windows filenames that contain Umlauts

1 March 2024 - 17:06

"The typemap is there to make sure the resulting string is utf-8 encoded".

 

So that is not true.

 

Let me try to explain with simple examples. So let's look at "fileeraser" and "trashcan"

	for root, dirs, files in os.walk(trash, topdown=False):
		for name in files:
			fn = os.path.join(root, name)
			try:
				fn = fn.encode(encoding="utf8", errors="ignore").decode(encoding="utf8")	# ensure string is all utf-8, if dataset name changed, erase will handle not found.  			
				enigma.eBackgroundFileEraser.getInstance().erase(fn)
			except Exception as e:
				print("[Trashcan] Failed to erase file:", name, "   ", e)
fn = fn.encode(encoding="utf8", errors="ignore").decode(encoding="utf8")	

So if we "ignore" that is not going to work and we end up with a filename that is wrong so impossible to erase... so... we want to read the filenames in bytes...

for root, dirs, files in os.walk(trash.encode(), topdown=False):	# handle non utf-8 filenames

To do that we encode the input.

trash.encode()

Now python returns bytes, not strings from the directory walk.

 

So now we want to pass that bytestring to "file_eraser.cpp". The result is a crash. c++ is expecting type std::string&, not bytes.

 

To accept the bytestring we add the typemap (as an extra, the old code still works on string inputs).

 

So now the bytesring from os.walk is fed to "file_eraser.cpp" and the file is successfully erased.

 

-------------------------------------------------------------------

 

The chardet code you can play with in the Python interpreter.

It stops the Python crash and displays the correct characters in the GUI.