You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openoffice.apache.org by Vladislav Stevanovic <st...@gmail.com> on 2013/10/15 02:09:28 UTC
BASIC and UTF-8
Hello,
As I can see, there is a lot of people who are using BASIC for macros. And
I too.
Problem is next: does anybody developing Basic?
Problem 1: for all who want to deal with characters outside of English
language we have big problem, for example, with print function. I can not
export Cyrillic characters.
Problem 2: This is an office suit. Problem is when I want export some data
in a brand new .xml document. I can not create this xml document without
meta files in zipped file.
If I look on OO forum, there are majority of users who deal with Basic. If
this is reality, what is problem for little polishing for Basic?
Regards,
Wlada
Re: BASIC and UTF-8
Posted by Vladislav Stevanovic <st...@gmail.com>.
Maybe will be easier for better understunding each other is to first look
here:
http://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=58328
Regards Wlada
2013/10/15 Fernand Vanrie <so...@pmgroup.be>
> Vladislav ,
>
> In Belgium we have to deal with at least 2 languages Dutch and French who
> have also a lot non asci characters, we use extenifly Basic and some times
> hwe have to decode some text to UTF-8 who works and we decode the stream
> plese find below some code to encode a stream before insertion in a
> document
>
> hope it helps
>
> Greetz Fernand
> oPipe = createUNOService ("com.sun.star.io.Pipe")
> oTextOutputStream = createUNOService ("com.sun.star.io.**
> TextOutputStream")
> oTextOutputStream.**setOutputStream(oPipe)
> oTextOutputStream.setEncoding(**"UTF-8") '"Windows-1252")
>
> szone = "some tekst with &้"''((งงง่่่!! non asci character
> 'print szone
> oTextOutputStream.writeString(**szone)
> ' at current viewcursor positiong
> InsertViaStream(opipe)
>
> sub InsertViaStream(oInputStream as Any)
> oStorageFac = createUnoService("com.sun.**star.embed.StorageFactory")
> oStorage = oStorageFac.createInstance
> oStream = oStorage.openStreamElement("**ms777", com.sun.star.embed.**
> ElementModes.WRITE)
>
> 'now pump the inputstream to the stream
> oPump = createUNOService ("com.sun.star.io.Pump")
> oPump.setInputStream(**oInputStream)
> oPump.setOutputStream(oStream)
> oPump.start()
>
> while oInputStream.available()>0
> wait(50)
> wend
> oStream.flush
> oStream.closeOutput
> oStream.dispose
> 'open the stream again, now for seekable reading
> oStream = oStorage.openStreamElement("**ms777", com.sun.star.embed.**
> ElementModes.SEEKABLEREAD)
> dim oProps(1) as new com.sun.star.beans.**PropertyValue
> oProps(0).Name = "InputStream"
> oProps(0).Value = ostream
> oProps(1).Name = "FilterName"
> oProps(1).VAlue = "HTML (StarWriter)"
>
>
> Dim oInsertCursor As Object
> if wat = "Cell" then
> oInsertCursor = oVC.cell.**createTextCursorByRange(oVC,**false)
> elseif wat = "Frame" then
> oInsertCursor = oVC.TextFrame.**createTextCursorByRange(oVC,**false)
> elseif wat = "Doc" then
> oInsertCursor = oVC.text.**createTextCursorByRange(oVC,**false)
> endif
> oInsertCursor.**InsertDocumentFromURL("" , oProps())
>
> opipe.flush
> opipe.closeinput
> ostorage.dispose
> ostream = nothing
> end sub
>
> Hello,
>> As I can see, there is a lot of people who are using BASIC for macros. And
>> I too.
>> Problem is next: does anybody developing Basic?
>> Problem 1: for all who want to deal with characters outside of English
>> language we have big problem, for example, with print function. I can not
>> export Cyrillic characters.
>> Problem 2: This is an office suit. Problem is when I want export some data
>> in a brand new .xml document. I can not create this xml document without
>> meta files in zipped file.
>> If I look on OO forum, there are majority of users who deal with Basic. If
>> this is reality, what is problem for little polishing for Basic?
>>
>> Regards,
>> Wlada
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: dev-unsubscribe@openoffice.**apache.org<de...@openoffice.apache.org>
> For additional commands, e-mail: dev-help@openoffice.apache.org
>
>
Re: BASIC and UTF-8
Posted by Fernand Vanrie <so...@pmgroup.be>.
Vladislav ,
In Belgium we have to deal with at least 2 languages Dutch and French
who have also a lot non asci characters, we use extenifly Basic and some
times hwe have to decode some text to UTF-8 who works and we decode the
stream
plese find below some code to encode a stream before insertion in a
document
hope it helps
Greetz Fernand
oPipe = createUNOService ("com.sun.star.io.Pipe")
oTextOutputStream = createUNOService ("com.sun.star.io.TextOutputStream")
oTextOutputStream.setOutputStream(oPipe)
oTextOutputStream.setEncoding("UTF-8") '"Windows-1252")
szone = "some tekst with &é"''((§§§èèè!! non asci character
'print szone
oTextOutputStream.writeString(szone)
' at current viewcursor positiong
InsertViaStream(opipe)
sub InsertViaStream(oInputStream as Any)
oStorageFac = createUnoService("com.sun.star.embed.StorageFactory")
oStorage = oStorageFac.createInstance
oStream = oStorage.openStreamElement("ms777",
com.sun.star.embed.ElementModes.WRITE)
'now pump the inputstream to the stream
oPump = createUNOService ("com.sun.star.io.Pump")
oPump.setInputStream(oInputStream)
oPump.setOutputStream(oStream)
oPump.start()
while oInputStream.available()>0
wait(50)
wend
oStream.flush
oStream.closeOutput
oStream.dispose
'open the stream again, now for seekable reading
oStream = oStorage.openStreamElement("ms777",
com.sun.star.embed.ElementModes.SEEKABLEREAD)
dim oProps(1) as new com.sun.star.beans.PropertyValue
oProps(0).Name = "InputStream"
oProps(0).Value = ostream
oProps(1).Name = "FilterName"
oProps(1).VAlue = "HTML (StarWriter)"
Dim oInsertCursor As Object
if wat = "Cell" then
oInsertCursor = oVC.cell.createTextCursorByRange(oVC,false)
elseif wat = "Frame" then
oInsertCursor = oVC.TextFrame.createTextCursorByRange(oVC,false)
elseif wat = "Doc" then
oInsertCursor = oVC.text.createTextCursorByRange(oVC,false)
endif
oInsertCursor.InsertDocumentFromURL("" , oProps())
opipe.flush
opipe.closeinput
ostorage.dispose
ostream = nothing
end sub
> Hello,
> As I can see, there is a lot of people who are using BASIC for macros. And
> I too.
> Problem is next: does anybody developing Basic?
> Problem 1: for all who want to deal with characters outside of English
> language we have big problem, for example, with print function. I can not
> export Cyrillic characters.
> Problem 2: This is an office suit. Problem is when I want export some data
> in a brand new .xml document. I can not create this xml document without
> meta files in zipped file.
> If I look on OO forum, there are majority of users who deal with Basic. If
> this is reality, what is problem for little polishing for Basic?
>
> Regards,
> Wlada
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@openoffice.apache.org
For additional commands, e-mail: dev-help@openoffice.apache.org
Re: BASIC and UTF-8
Posted by Andrew Douglas Pitonyak <an...@pitonyak.org>.
On 10/14/2013 08:09 PM, Vladislav Stevanovic wrote:
> Hello,
> As I can see, there is a lot of people who are using BASIC for macros. And
> I too.
> Problem is next: does anybody developing Basic?
> Problem 1: for all who want to deal with characters outside of English
> language we have big problem, for example, with print function. I can not
> export Cyrillic characters.
> Problem 2: This is an office suit. Problem is when I want export some data
> in a brand new .xml document. I can not create this xml document without
> meta files in zipped file.
> If I look on OO forum, there are majority of users who deal with Basic. If
> this is reality, what is problem for little polishing for Basic?
>
> Regards,
> Wlada
>
I feel silly asking this, but is the same true for MsgBox and inside of
a dialog that you create with a text display field that you populate
from a macro?
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@openoffice.apache.org
For additional commands, e-mail: dev-help@openoffice.apache.org
Re: BASIC and UTF-8
Posted by Ariel Constenla-Haile <ar...@apache.org>.
Hi,
On Tue, Oct 15, 2013 at 02:09:28AM +0200, Vladislav Stevanovic wrote:
> Hello,
> As I can see, there is a lot of people who are using BASIC for macros. And
> I too.
> Problem is next: does anybody developing Basic?
> Problem 1: for all who want to deal with characters outside of English
> language we have big problem, for example, with print function. I can not
> export Cyrillic characters.
Looking at this example, there are some bug, please open a bug report:
Sub Main
Dim aLines()
aLines = Array(_
"Мой дядя самых честных правил,",_
"Когда не в шутку занемог,",_
"Он уважать себя заставил",_
"И лучше выдумать не мог.",_
"Его пример другим наука;",_
"Но, боже мой, какая скука",_
"С больным сидеть и день и ночь,",_
"Не отходя ни шагу прочь!",_
"Какое низкое коварство",_
"Полуживого забавлять,",_
"Ему подушки поправлять,",_
"Печально подносить лекарство,",_
"Вздыхать и думать про себя:",_
"Когда же черт возьмет тебя!" _
)
Dim n%
Dim s$
For n = 0 To Ubound(aLines)
s = s + aLines(n) + Chr(13)
Next
MsgBox s, 0, "Пушкин, Евгений Онегин"
print s
End Sub
> Problem 2: This is an office suit. Problem is when I want export some data
> in a brand new .xml document. I can not create this xml document without
> meta files in zipped file.
I don't get this, can you reformulate it? Are you trying to write
a plain XML file, or an ODT file, or a zip file, or ...?
In any case, I would use the API, even if writing the code in Basic,
instead of Basic functions (that is, do not use print to write to
a file, use the API from the com.sun.star.io module).
Note: there is a dedicate mailing list for API questions
api@openoffice.apache.org
Regards
--
Ariel Constenla-Haile
La Plata, Argentina