How to check for an encoding of a file under Linux - example

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to check for an encoding of a file under Linux - example

GLASS mailing list

GsHostProcess class>mskCheckFileEncoding: source
" ^<String> Returns the mime-encoding of a single file

  Example: GsHostProcess  mskCheckFileEncoding: '/home/mf/Schreibtisch/217055.csv'

"
| output aWriteStream readStream |

aWriteStream := WriteStream on: String new.
aWriteStream
   nextPutAll: 'file --mime-encoding ' ;
  nextPut: $' ;
   nextPutAll: source  ;
  nextPut: $'.

output := System performOnServer: aWriteStream contents.
readStream := ReadStream on: output.
readStream throughAll: source ; throughAll: ':'.
^readStream upToEnd trimBlanks


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: How to check for an encoding of a file under Linux - example

GLASS mailing list

Better is this :

GsHostProcess class>mskCheckFileEncoding: source
" ^<String> Returns the mime-encoding of a single file

  Example: GsHostProcess  mskCheckFileEncoding: '/home/mf/Schreibtisch/217055.csv'

"
| output aWriteStream readStream |

aWriteStream := WriteStream on: String new.
aWriteStream
   nextPutAll: 'file --mime-encoding ' ;
  nextPut: $' ;
   nextPutAll: source  ;
  nextPut: $'.

output := System performOnServer: aWriteStream contents.
readStream := ReadStream on: output.
readStream throughAll: source ; throughAll: ':'.
^readStream upToEnd trimBlanks trimSeparators


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass