[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is there a gambas way to detect a files charset?


Can gambas do what I'm doing with the file command here detecting the files
charset for conversion to UTF8?


Public Sub FileLoadUTF8(Path As String) As String

 Dim sEncode As String
 Shell "file -b --mime-encoding " & Shell(Path) Wait To sEncode
 if sEncode Like "utf-8" Then
  Return File.Load(Path)
Else
 Return Conv(File.Load(Path), RTrim(sEncode), "UTF-8")
 Endif

End

Or would using the file command be the best way?
Respects
BruceS