Page 1 of 1

[Solved] High unicode numbers in Chr()

Posted: Wed May 08, 2019 12:52 am
by mango
I want to use musical symbols. Some of them get very high unicode numbers as 119070. I tried to use the Chr-method, i.e. Chr(119070). That ended in an overflow-message. Entering Hex-Code to Chr did not work either.
Is that because there is a (byte) limit using Chr, do I have to load musical symbols (how will that work) to include them into Open Office or what else could I do to get access to these symbols?
Many thanks

Re: High unicode numbers in Chr()

Posted: Wed May 08, 2019 1:24 am
by JeJe
Chr only supports up to 16 bit Unicode values - that's in the help file. If you look at the special characters dialog - it only has characters in that range too. And when I tried copying and pasting the musical symbols it didn't work.

So it looks like you're out of luck and Openoffice doesn't support these symbols.

Edit: I guess you could create a picture using the symbol you want and insert that instead.

Edit2: There might be a special font that has those symbols - I don't know.

Re: High unicode numbers in Chr()

Posted: Wed May 08, 2019 1:35 am
by RusselB
Chr (CHAR is the Calc function) are limited to 1-255.... so 119070 is way too high.
From the help file
CHAR
Converts a number into a character according to the current code table. The number can be a two-digit or three-digit integer number.
Codes greater than 127 may depend on your system's character mapping (for example iso-8859-1, iso-8859-2, Windows-1252, Windows-1250), and hence may not be portable.
Syntax
CHAR(Number)
Number is a number between 1 and 255 representing the code value for the character.
Example
=CHAR(100) returns the character d.
="abc" & CHAR(10) & "def" inserts a newline character into the string.
For musical notes (not sure how they relate to Calc, as there's no math that can be done with them, to my knowledge), you could try using Insert -> Special Character

It's been a long time since I had anything to do with musical notation, and I don't know which note(s) you're wanting, so you'll have to go through the various options until you find something that works for you,

Since you are working with unicode characters, the UNICHAR function might be better suited....as a, possible, easier method than using Insert -> Special Character

Re: High unicode numbers in Chr()

Posted: Wed May 08, 2019 2:03 am
by RusselB
A quick test of

Code: Select all

=UNICHAR(119070)
didn't give me a musical note that I recognized, but then again that may be due to the font.
It also didn't give me any kind of error message, so the code was accepted.

Re: High unicode numbers in Chr()

Posted: Wed May 08, 2019 7:14 am
by Zizi64
I want to use musical symbols. Some of them get very high unicode numbers as 119070.
Chr only supports up to 16 bit Unicode values - that's in the help file.
The Unicode 12.0 version adds 554 characters, for a total of 137,928 characters, and this number will be increased in the future.

No one character set will support all of these characters, because the relevant font file should be too huge to storing the vector graphic informations for all of the characters.


You need use a partial character set like the Lilypond or others.
http://lilypond.org/doc/v2.18/Documenta ... fonts.html

Re: High unicode numbers in Chr()

Posted: Wed May 08, 2019 1:00 pm
by Lupp
You may try:
http://doc.rhavin.de/MuML/ See "How to use". There's a link to the suggested font QMuML9.ttf.
The application of that font shouldn't be limited to the "Musical Markup Language V0.6.1" described on that page.
The page also is asking for a contribution of €5.00 (five EURO).

Among the rather few glyphs coming with that .ttf, there is no G clef, however. Therefore I would assume most of the musical symbols are supposed to be accessible on current systems anyway.

My LibO V 6.2.3 and also AOO V 4.1.5 on Win 10 obviously have access to fonts containing the violin clef (what the given unicode place is) and replace their standard font "transparently" iof needed. That's the kind of transparence making it difficult to identify what actually happened.

Re: High unicode numbers in Chr()

Posted: Wed May 08, 2019 1:24 pm
by JeJe
Don't know whether these have what you want but some fonts here:

https://www.smufl.org/fonts/

There are also plenty of font editors around to customise a font... reassign glyphs to codepoints within the integer range perhaps?

Re: High unicode numbers in Chr()

Posted: Wed May 08, 2019 3:37 pm
by Zizi64
The MuseScore is an excellent free sheet music maker software:

https://musescore.org/en

You can create sheet music pages, and then you can embed it into the Writer (as an image) - if it necessary.
https://musescore.org/en/node/10398

Re: High unicode numbers in Chr()

Posted: Fri May 10, 2019 1:00 am
by mango
Thanks all for your answers
I really need only four symbols up to now: musical sharp sign (9839), musical flat sign (9837), violin clef (119070), bass clef (119074). Chr(9839) and Chr(9839) work on my system.
I downloaded Bravura text Font for musical symbols and installed it. I can see the symbols in the Windows character table, but only the Hex-numbers seem to be displayed.
Anyway, how would I now address this font in LO or Apache. Do I have to include the font inside the installation directory of LO or Apache? Or include it at the beginning of the script, are there some methods I could use or can I directly address the symbols ?
Unichar didn't work with my installation, what could be the reason of this?

Re: High unicode numbers in Chr()

Posted: Fri May 10, 2019 1:07 am
by RusselB
If your font has been properly installed in Windows, then OpenOffice should recognize it upon the start up of OpenOffice.
Ie: In order to see the font in Calc, make sure that Calc is not running when you do the installation.
As to UNICHAR, if you entered it correctly, as I showed in my earlier post, then I can't think of any reason it wouldn't work.
Saying that it didn't work is, realistically, useless for us to try to determine a reason... Did you get an error message? If so, what was the message.. please be precise.
If no error message, then what did you get that indicates to you that the function didn't work?

Re: High unicode numbers in Chr()

Posted: Fri May 10, 2019 10:25 am
by Lupp
(Just to emphasize this once more:)
It's not a matter of OpenOffice having problems with high unicode places. On my Win-10-system AOO 4.1.5 recognizes all the mentioned unicodes used with UNICHAR() as expected without any additional measures.

Re: High unicode numbers in Chr()

Posted: Fri May 10, 2019 10:51 am
by Zizi64
My LibreOffice 6.1.5 portable version can show the characters with the built-in default character set named Liberation Sans:
unichar.png

Re: High unicode numbers in Chr()

Posted: Sat May 11, 2019 12:32 am
by mango
That would be good news, I got the same font installed.
But UNICHAR does not work with my installation (LO 6.2.3.2 x64), neither with direct cell input, nor in scripting. Do I have to install an add-on?

Re: High unicode numbers in Chr()

Posted: Sat May 11, 2019 12:48 am
by Lupp
Might you tell us what you get instead of what you don't get, please?

Re: High unicode numbers in Chr()

Posted: Sat May 11, 2019 7:30 am
by Zizi64
But UNICHAR does not work with my installation (LO 6.2.3.2 x64), neither with direct cell input, nor in scripting. Do I have to install an add-on?
Yes. Maybe that extension is named as "Windows 10" :D :D :D
it is very strange: While the UNICHAR() function worked fine for me at work on my Win10 machine, it not work on my Win7 machine at home - with same LO version. And Lupp tried it on Win10 too.

But your signature is:
Apache Open Office 4.1.6 on Windows 10

I do not know, what causes the difference on same op.sys. and with same LO version...
Do you have x64 version of the Win10?
What version of Java have you installed?

Re: High unicode numbers in Chr()

Posted: Sun May 12, 2019 3:26 am
by mango
I updated Java to its newest version Java 8 Update 211, it doesn't work either.
My signature is Apache 4.1.6, but in the course of the problems I met with shifted shapes I installed LO 6.2.3.2
I'm working with Windows10, x64. I didn't yet try, if it works with Apache.
When I use unichar in my macro I get a runtime error, saying that procudure sub or function is undefined.
Using it as cell input, I get #NAME?

Re: High unicode numbers in Chr()

Posted: Sun May 12, 2019 7:33 am
by Zizi64
When I use unichar in my macro I get a runtime error, saying that procudure sub or function is undefined.
The UNICHAR is a CELL function. You can call it from a Basic macro, but you can not use a simple calling by its name.
Search in this forum for examples: how to call the cell functions from a macro.
The list of the Built-in Basic functions are in the help: There are some MS VBA compatible functions, like the CharW(). You must use the statement,

Code: Select all

option vbasupport 1
if you want use them.
Be careful! The option vbasupport 1 will degrade the normal Chr() function to 8 bit parameters in the specific Module. (I just tried it.) And even the ChrW() can handle the 16 bit wide Unicode characters only.
https://help.libreoffice.org/latest/he/ ... 03350.html


Using it as cell input, I get #NAME?
That means you are using the LO with localized settings. Switch to English function names and try it again:
Tools - Options - LibreOffice Calc - Formula - Use English function names
Or search the relevant function name for your locale setting.
The Hungarian function name is UNIKARAKTER()

Re: High unicode numbers in Chr()

Posted: Sun May 12, 2019 2:06 pm
by Lupp
For testing the API-based solution:

Code: Select all

fa = createUnoService("com.sun.star.sheet.FunctionAccess")
ch = fa.CallFunction("UNICHAR", Array(119070))
Print ch
co = fa.CallFunction("UNICODE", Array(ch))
Print co
(This also works if called for any different model. Writer, Draw, ...)

Re: High unicode numbers in Chr()

Posted: Sun May 12, 2019 11:31 pm
by mango
Thanks all for your help, guys
I tried
fa = createUnoService("com.sun.star.sheet.FunctionAccess")
ch = fa.CallFunction("UNICHAR", Array(119070))
and that did the trick. I put that into a TextShape and I could clearly see a violin clef.
One question about that still: Why do I have to set the second argument as an array?
Thanks again

Re: High unicode numbers in Chr()

Posted: Sun May 12, 2019 11:44 pm
by Lupp
mango wrote:Why do I have to set the second argument as an array?
The two arguments of the callFunction method are typed and mandatory. The second one is typed as a 1D-array of element type Variant. It must be present even if the function is expecting 0 arguments. In other words: The array is the equivalent of the complete parameter-part of a function call.

The reported success is a surpise in a sense. If the macro approach worked, your LibO must have access to a font providing the glyph. A probably needed replacement automatism must also have worked. Why shouldn't a Calc cell then show the clef for =UNICHAR(119070) on your system as it does on mine? Or did I misunderstand the situation insofar?

Re: [Solved] High unicode numbers in Chr()

Posted: Mon May 13, 2019 10:41 pm
by mango
Yes, that's strange. I tried it again: entering =UNICHAR(119070) into a cell ends up in =NAME? .
Regarding the font, I got Liberation Sans on my system (the one Tibor said, it would contain violin clef) and additionally installed Bravura, so the symbols should be accessible. Does that FunctionAccess provide a more universal way to access additional functions? Would be nice to understand that.

Re: [Solved] High unicode numbers in Chr()

Posted: Tue May 14, 2019 2:40 am
by RusselB
Zizi64 wrote:That means you are using the LO with localized settings. Switch to English function names and try it again:
Tools - Options - LibreOffice Calc - Formula - Use English function names
Or search the relevant function name for your locale setting.

Re: [Solved] High unicode numbers in Chr()

Posted: Tue May 14, 2019 11:55 pm
by mango
Thanks for reminding me; I forgot to try that.
That was the reason. Now UNICHAR works.
Thanks again to all for supporting me on that.

Re: [Solved] High unicode numbers in Chr()

Posted: Wed May 15, 2019 6:47 am
by Zizi64
Yes, it works on Windows 10, but it can not work for me on Windows 7 anyway...