Browse Source

Merge branch 'master' of http://git.choozmo.com:3000/ai-anchor/video-maker

tomoya 1 năm trước cách đây
mục cha
commit
9d0a3313e6
1 tập tin đã thay đổi với 17 bổ sung0 xóa
  1. 17 0
      backend/app/app/core/test_chardet.py

+ 17 - 0
backend/app/app/core/test_chardet.py

@@ -0,0 +1,17 @@
+from chardet.universaldetector import UniversalDetector
+
+DEFAULT_ENCODING = "utf-8"
+
+def guess_codec(filenames: list) -> str:
+  codec_detector = UniversalDetector()
+  for filename in filenames:
+    codec_detector.feed(filename.encode('cp437'))
+    if codec_detector.done:
+      break
+
+  result = codec_detector.close()
+  encoding = result.get("encoding")
+  return encoding or DEFAULT_ENCODING
+  
+if __name__=="__main__":
+  pass