[Solved] Display a file with utf-8 format with macro
[Solved] Display a file with utf-8 format with macro
hi;
i'm trying to open a file with soffice GUI. after choosing the file to display the open office prompt the window " ascii filter options " as the file contains Arabic words so choosing the UTF-8 in character set permit to display the file properly.
i'm looking to create a macro to open the file as UTF-8 I created the 2 subs below
sub test5
oDoc = ThisComponent
url= ConvertToUrl ("/u/batch/test.utf8")
dim exportdata(0) as new com.sun.star.beans.PropertyValue
exportdata(0).Name = "FilterOptions"
exportdata(0).Value = "76"
oDoc = starDesktop.loadComponentFromURL(url, "_blank", 0, exportdata())
End sub
also I created the below sub
sub test6
oDoc = ThisComponent
url= ConvertToUrl ("/u/batch/test.utf8")
dim exportdata(0) as new com.sun.star.beans.PropertyValue
exportdata(0).Name = "FilterOptions"
exportdata(0).Value = "76"
oDoc = starDesktop.loadComponentFromURL(url, "_blank", 0, exportdata())
End sub
both subs still showing the Arabic characters as encrypted despite that when opening with soffice GUI the file is presented properly.
i'm trying to open a file with soffice GUI. after choosing the file to display the open office prompt the window " ascii filter options " as the file contains Arabic words so choosing the UTF-8 in character set permit to display the file properly.
i'm looking to create a macro to open the file as UTF-8 I created the 2 subs below
sub test5
oDoc = ThisComponent
url= ConvertToUrl ("/u/batch/test.utf8")
dim exportdata(0) as new com.sun.star.beans.PropertyValue
exportdata(0).Name = "FilterOptions"
exportdata(0).Value = "76"
oDoc = starDesktop.loadComponentFromURL(url, "_blank", 0, exportdata())
End sub
also I created the below sub
sub test6
oDoc = ThisComponent
url= ConvertToUrl ("/u/batch/test.utf8")
dim exportdata(0) as new com.sun.star.beans.PropertyValue
exportdata(0).Name = "FilterOptions"
exportdata(0).Value = "76"
oDoc = starDesktop.loadComponentFromURL(url, "_blank", 0, exportdata())
End sub
both subs still showing the Arabic characters as encrypted despite that when opening with soffice GUI the file is presented properly.
Last edited by Hagar Delest on Wed Mar 15, 2017 9:38 pm, edited 1 time in total.
Reason: tagged [Solved].
Reason: tagged [Solved].
open office version: 3.3.0
operating system : solaris 10 ( sparc 5.10)
operating system : solaris 10 ( sparc 5.10)
Re: display a file with utf-8 format with macro openOffice
Is it a pure .txt file or it has other fileformat?i'm trying to open a file with soffice GUI.
Maybe it is a missing font problem.both subs still showing the Arabic characters as encrypted despite that when opening with soffice GUI the file is presented properly.
Can you upload your example file here?
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: display a file with utf-8 format with macro openOffice
attached is the file.
when I open it via the soffice gui when I define character set to utf-8 in ascii filter options in window prompt it is displaying correctly.
the macro is still showing them as encrypted.
when I open it via the soffice gui when I define character set to utf-8 in ascii filter options in window prompt it is displaying correctly.
the macro is still showing them as encrypted.
open office version: 3.3.0
operating system : solaris 10 ( sparc 5.10)
operating system : solaris 10 ( sparc 5.10)
Re: display a file with utf-8 format with macro openOffice
There is not any attached file in your posts of this thread. The file size limit is 128 KiB in this Forum. You can share the larger files with a free file sharing service (like the Google drive)attached is the file.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: display a file with utf-8 format with macro openOffice
the file attached below.
the file format is utf8
the file format is utf8
- Attachments
-
- test.avi.utf8.txt
- file
- (598 Bytes) Downloaded 261 times
open office version: 3.3.0
operating system : solaris 10 ( sparc 5.10)
operating system : solaris 10 ( sparc 5.10)
Re: Display a file with utf-8 format with macro OpenOffice
Open the .txt file with a pure text editor.
I Just copy-pasted the text from the Notepad into the LibreOffice 4.4.7:
I Just copy-pasted the text from the Notepad into the LibreOffice 4.4.7:
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: Display a file with utf-8 format with macro OpenOffice
i'm using open office 3.3 on solaris sparc 5.10 when I open it via soffice it still open encrypted.
the file that I sent you is converted via iconv to utf8 . in windows I can display the charcters but in solaris via soffice no.
attached the image of the soffice
the file that I sent you is converted via iconv to utf8 . in windows I can display the charcters but in solaris via soffice no.
attached the image of the soffice
open office version: 3.3.0
operating system : solaris 10 ( sparc 5.10)
operating system : solaris 10 ( sparc 5.10)
Re: Display a file with utf-8 format with macro OpenOffice
sorry, there is absolutly no problem with:
Code: Select all
sub test
oDoc = ThisComponent
url= ConvertToUrl ("/u/batch/test.utf8")
other_Doc = starDesktop.loadComponentFromURL( url, "_blank", 0, array() )
End sub
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
Re: Display a file with utf-8 format with macro OpenOffice
That is a very-very old version...i'm using open office 3.3
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
- Sébastien C
- Posts: 111
- Joined: Mon Jan 04, 2010 5:06 pm
- Location: Meymac, France
Re: Display a file with utf-8 format with macro OpenOffice
Hello everyone
If I may ... Two solutions
and
Enjoy !
If I may ... Two solutions
Code: Select all
Sub ReadEncodedText1()
Dim props(1) As New com.sun.star.beans.PropertyValue
Dim url As String
url = convertToURL("/u/batch/test.utf8")
props(0).Name = "FilterName" : props(0).Value = "Text (encoded)"
props(1).Name = "FilterOptions" : props(1).Value = "UTF8,LF"
oDoc = StarDesktop.loadComponentFromURL(url, "_blank", 0, props())
End Sub
Code: Select all
Sub ReadEncodedText2()
Dim myTextFile As Object, sf As Object, fileStream As Object
Dim aLineOfText As String, url As String
url = convertToUrl ("/u/batch/test.utf8")
sf = createUnoService("com.sun.star.ucb.SimpleFileAccess")
On Error Goto fichierKO
fileStream = sf.openFileRead(url)
myTextFile = createUnoService("com.sun.star.io.TextInputStream")
myTextFile.InputStream = fileStream
myTextFile.Encoding = "UTF-8"
Do while not myTextFile.IsEOF
aLineOfText = myTextFile.readLine
msgBox(aLineOfText)
Loop
fileStream.closeInput : myTextFile.closeInput
On Error Goto 0
Exit Sub
FichierKO:
Resume FichierKO2
FichierKO2:
On Error Resume Next
msgBox("File read error !", 16)
fileStream.closeInput : myTextFile.closeInput
On Error Goto 0
End Sub
LibreOffice v. 7.3.2.2, under GNU-Linux Mint and, in virtualization and just for tests, LibreOffice v. 7.3.2.2 an OpenOffice v. 4.1.12 under M$-W 10 .
Re: Display a file with utf-8 format with macro OpenOffice
Hello sebastien
I tried the first sub it still scrambling the characters.
do you have any idea on how to display in macro the image attached below.
I tried the first sub it still scrambling the characters.
do you have any idea on how to display in macro the image attached below.
open office version: 3.3.0
operating system : solaris 10 ( sparc 5.10)
operating system : solaris 10 ( sparc 5.10)
Re: Display a file with utf-8 format with macro OpenOffice
Hi sebastien;
i'm getting them as per your first sub as showing below in the image. any idea on how to progress more and get the Arabic words
i'm getting them as per your first sub as showing below in the image. any idea on how to progress more and get the Arabic words
open office version: 3.3.0
operating system : solaris 10 ( sparc 5.10)
operating system : solaris 10 ( sparc 5.10)
- Sébastien C
- Posts: 111
- Joined: Mon Jan 04, 2010 5:06 pm
- Location: Meymac, France
Re: Display a file with utf-8 format with macro OpenOffice
Sorry, but this code works well at home. And I also agree with “Zizi64” that your softwares are a bit prehistorics
I have no idea to make you display your dialog box
BUT
It seems that it is your default font that handles very badly the UTF8 ...
Start by locating a font that, since OpenOffice, handles Arabic characters. Let's call it “DejaVu Serif”. Then, try to correct the right line by:
In other words, you force
I have no idea to make you display your dialog box
BUT
It seems that it is your default font that handles very badly the UTF8 ...
Start by locating a font that, since OpenOffice, handles Arabic characters. Let's call it “DejaVu Serif”. Then, try to correct the right line by:
Code: Select all
props(1).Name = "FilterOptions" : props(1).Value = "UTF8,CRLF,DejaVu Serif,en-CA"
- UTF8 : general encoding
- CRLF : end lines encoding
- DejaVu Serif : The font
- En-CA : The language of the file
LibreOffice v. 7.3.2.2, under GNU-Linux Mint and, in virtualization and just for tests, LibreOffice v. 7.3.2.2 an OpenOffice v. 4.1.12 under M$-W 10 .
Re: Display a file with utf-8 format with macro OpenOffice
thanks sebastien the first one work well but i had problem with the file. thanks a lot for your time.
open office version: 3.3.0
operating system : solaris 10 ( sparc 5.10)
operating system : solaris 10 ( sparc 5.10)
Re: Display a file with utf-8 format with macro OpenOffice
with this sub the issue was fixed.
sub test5 ()
cFile="/u/batch/test.utf8"
rem oDoc = ThisComponent
url = ConvertToUrl (cFile)
Dim FileProperties(1) As New com.sun.star.beans.PropertyValue
FileProperties(0).Name = "FilterName"
FileProperties(0).Value ="Text (encoded)"
FileProperties(1).Name = "FilterOptions"
FileProperties(1).Value ="UTF8,LF"
oDoc = starDesktop.loadComponentFromURL(url, "_blank", 0, FileProperties())
sub test5 ()
cFile="/u/batch/test.utf8"
rem oDoc = ThisComponent
url = ConvertToUrl (cFile)
Dim FileProperties(1) As New com.sun.star.beans.PropertyValue
FileProperties(0).Name = "FilterName"
FileProperties(0).Value ="Text (encoded)"
FileProperties(1).Name = "FilterOptions"
FileProperties(1).Value ="UTF8,LF"
oDoc = starDesktop.loadComponentFromURL(url, "_blank", 0, FileProperties())
open office version: 3.3.0
operating system : solaris 10 ( sparc 5.10)
operating system : solaris 10 ( sparc 5.10)
Re: Display a file with utf-8 format with macro OpenOffice
Sébastien,Sébastien C wrote:Sorry, but this code works well at home. And I also agree with “Zizi64” that your softwares are a bit prehistorics
I have no idea to make you display your dialog box
BUT
It seems that it is your default font that handles very badly the UTF8 ...
Start by locating a font that, since OpenOffice, handles Arabic characters. Let's call it “DejaVu Serif”. Then, try to correct the right line by:
In other words, you forceCode: Select all
props(1).Name = "FilterOptions" : props(1).Value = "UTF8,CRLF,DejaVu Serif,en-CA"
Is it better
- UTF8 : general encoding
- CRLF : end lines encoding
- DejaVu Serif : The font
- En-CA : The language of the file
How/where did you find the right filter options?
Edit: OK. I found out by opening the file as file type "Text - Choose Encoding" and then inspect ThisComponent.Args() |
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
- Sébastien C
- Posts: 111
- Joined: Mon Jan 04, 2010 5:06 pm
- Location: Meymac, France
Re: Display a file with utf-8 format with macro OpenOffice
As you know I am French and I read easily the fr-FR...
And in FR, we have the incredible chance to have the Bible written in fr ... Even if Andrew Pitonyak is a reference, it's MUCH MORE organized, laid out, structured.
It is very easy to find this text in pirated PDF in a relatively recent version, but I will not give the link here. The price of the rights of the book is totally donated to the community and the authors do not receive any money.
I did a search G***** with (in quotes) "UTF8" and "com.sun.star.beans.PropertyValue".
It brought me back to Bernard Marcelly's bible, a page that G***** gives to read.
But if you want the list of ALL filters, then Andrew Pitonyak is better ... On page 218 of the PDF, for example.
And in FR, we have the incredible chance to have the Bible written in fr ... Even if Andrew Pitonyak is a reference, it's MUCH MORE organized, laid out, structured.
It is very easy to find this text in pirated PDF in a relatively recent version, but I will not give the link here. The price of the rights of the book is totally donated to the community and the authors do not receive any money.
I did a search G***** with (in quotes) "UTF8" and "com.sun.star.beans.PropertyValue".
It brought me back to Bernard Marcelly's bible, a page that G***** gives to read.
But if you want the list of ALL filters, then Andrew Pitonyak is better ... On page 218 of the PDF, for example.
LibreOffice v. 7.3.2.2, under GNU-Linux Mint and, in virtualization and just for tests, LibreOffice v. 7.3.2.2 an OpenOffice v. 4.1.12 under M$-W 10 .