OpenOffice 3.3.0 macro to save file as UTF8
Posted: Tue Mar 14, 2017 3:08 pm
hi,
i'm trying to create a macro that permit to open and save an existing file( that is not utf8) as UTF8 charset so the file can display correctly all characters specially arabic characters.
the below sub permit to convert a string to utf-8
sub write_string_to_path( path, mytext, encoding )
fileaccess = createUnoService ("com.sun.star.ucb.SimpleFileAccess")
outtextstream = createUnoService ("com.sun.star.io.TextOutputStream")
outtextstream.setEncoding( encoding )
out = fileaccess.openFileWrite( path )
outtextstream.setOutputStream( out )
outtextstream.writeString( mytext )
outtextstream.closeOutput()
End Sub
how to alter it to pass a text stream or a file instead of a predefined string, or exist another macro that permit to save a file as utf8.
i'm trying to create a macro that permit to open and save an existing file( that is not utf8) as UTF8 charset so the file can display correctly all characters specially arabic characters.
the below sub permit to convert a string to utf-8
sub write_string_to_path( path, mytext, encoding )
fileaccess = createUnoService ("com.sun.star.ucb.SimpleFileAccess")
outtextstream = createUnoService ("com.sun.star.io.TextOutputStream")
outtextstream.setEncoding( encoding )
out = fileaccess.openFileWrite( path )
outtextstream.setOutputStream( out )
outtextstream.writeString( mytext )
outtextstream.closeOutput()
End Sub
how to alter it to pass a text stream or a file instead of a predefined string, or exist another macro that permit to save a file as utf8.