From: A. H. <ang...@ua...> - 2012-03-11 17:48:41
|
Dear users I'd like to know if any on you has experience with displaying Unicode characters in Jmol echos. I have succesfully used single characters some times, using the \u notation. But what I need now is to enter from keyboard strings that include accented letters in a script file and have them properly displayed inside Jmol. Test 1: I have an html file, encoded as iso-8859-1, and a JmolScript file, encoded also as "Western Europe" (the default in Windows, may be the same as ANSI but I'm not sure). This works fine and the accented characters display correctly in the applet. Test 2: I wanted to switch to Unicode UTF-8 (as the files will be run from a Mac I thought this was a better option, since AFAIK Unicode is the default in MacOS). So I changed the html file to use Unicode UTF-8 (also declared as such in the meta tag) and saved it as such. I converted and re-saved the script file as UTF-8 too (without BOM). Now Jmol displays funny characters instead of the proper accented letters. I was assuming that the applet would receive whatever text based on the coding of the file and the coding/charset declaration of the webpage. I will appreciate any hints. Thanks |
From: Robert H. <ha...@st...> - 2012-03-11 21:16:11
|
examples? 2012/3/11 Angel Herráez <ang...@ua...> > Dear users > I'd like to know if any on you has experience with displaying Unicode > characters in Jmol > echos. > I have succesfully used single characters some times, using the \u > notation. But what I need > now is to enter from keyboard strings that include accented letters in a > script file and have > them properly displayed inside Jmol. > > Test 1: > I have an html file, encoded as iso-8859-1, and a JmolScript file, encoded > also as "Western > Europe" (the default in Windows, may be the same as ANSI but I'm not sure). > This works fine and the accented characters display correctly in the > applet. > > Test 2: > I wanted to switch to Unicode UTF-8 (as the files will be run from a Mac I > thought this was a > better option, since AFAIK Unicode is the default in MacOS). > So I changed the html file to use Unicode UTF-8 (also declared as such in > the meta tag) and > saved it as such. I converted and re-saved the script file as UTF-8 too > (without BOM). > Now Jmol displays funny characters instead of the proper accented letters. > > I was assuming that the applet would receive whatever text based on the > coding of the file > and the coding/charset declaration of the webpage. > I will appreciate any hints. > Thanks > > > > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > Jmol-users mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-users > -- Robert M. Hanson Professor of Chemistry St. Olaf College 1520 St. Olaf Ave. Northfield, MN 55057 http://www.stolaf.edu/people/hansonr phone: 507-786-3107 If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 |
From: Otis R. <osr...@ch...> - 2012-03-11 21:34:02
|
I'm not sure this is relevant because I've always been a bit confused on this subject. But I put a lot of sweat equity into putting an Angstrom symbol into an echo a while back. I'll paste the JavaScript function for this below: function doVdw() { var vdw = "echo Calculating...;delay 1;select *;isosurface select {*} resolution 6 MOLECULAR area;isosurface translucent;delay 2;var x = \"vdw surface area = \" + isosurfaceArea[0] % 0 + \" \u212B<sup>2</sup>\";echo @x"; doClean(); jmolScript(vdw); } The relevant snippet is at the end of the var vwd = declaration. I arrived at this by more trial and error than I care to remember. Otis -- Otis Rothenberger ot...@ch... http://chemagic.com On Mar 11, 2012, at 4:45 PM, Robert Hanson wrote: > examples? > > 2012/3/11 Angel Herráez <ang...@ua...> > Dear users > I'd like to know if any on you has experience with displaying Unicode characters in Jmol > echos. > I have succesfully used single characters some times, using the \u notation. But what I need > now is to enter from keyboard strings that include accented letters in a script file and have > them properly displayed inside Jmol. > > Test 1: > I have an html file, encoded as iso-8859-1, and a JmolScript file, encoded also as "Western > Europe" (the default in Windows, may be the same as ANSI but I'm not sure). > This works fine and the accented characters display correctly in the applet. > > Test 2: > I wanted to switch to Unicode UTF-8 (as the files will be run from a Mac I thought this was a > better option, since AFAIK Unicode is the default in MacOS). > So I changed the html file to use Unicode UTF-8 (also declared as such in the meta tag) and > saved it as such. I converted and re-saved the script file as UTF-8 too (without BOM). > Now Jmol displays funny characters instead of the proper accented letters. > > I was assuming that the applet would receive whatever text based on the coding of the file > and the coding/charset declaration of the webpage. > I will appreciate any hints. > Thanks > > > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > Jmol-users mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-users > > > > -- > Robert M. Hanson > Professor of Chemistry > St. Olaf College > 1520 St. Olaf Ave. > Northfield, MN 55057 > http://www.stolaf.edu/people/hansonr > phone: 507-786-3107 > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/_______________________________________________ > Jmol-users mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-users |
From: A. H. <ang...@ua...> - 2012-03-12 09:27:40
|
Thanks, Otis and Bob Otis, yes, the \u + unicode for inserting single characters works fine. But here I need to just type in Spanish texts into a script file and have them come out correct. My testing suggests that Java reads this file always as ANSI / ISO Western even when the file is coded as UTF-8 / Unicode. It does not make any difference whether the page is coded in one or the other. (I'm working on WinXP, Java 1.6.0_31) Past experience with javascript files says that they are assumed to be in the same encoding as the html page. This being a JmolScript file seems to not apply the same. Bob, I've put simple test pages at: http://biomodel.uah.es/Jmol/UTF8/test-ISO.htm http://biomodel.uah.es/Jmol/UTF8/test-UTF.htm |
From: Robert H. <ha...@st...> - 2012-03-12 16:03:58
|
Well, it seems to me if you say you are using UTF-8 and then you don't, that's a serious problem. It's all in the JavaScript and how it is translating the strings in your .js file. The problem is outside Jmol. Nothing to do with Jmol. So your real problem, I think, is that your text editor is not saving the text in UTF-8. You have to fix that first. Notepad, for instance, has a UTF-8 save option. Then ó becomes <C3> <B3> in the file instead of <F3>. that's almost certainly the problem. 2012/3/12 Angel Herráez <ang...@ua...> > Thanks, Otis and Bob > > Otis, yes, the \u + unicode for inserting single characters works > fine. > But here I need to just type in Spanish texts into a script file and > have them come out correct. My testing suggests that Java reads this > file always as ANSI / ISO Western even when the file is coded as > UTF-8 / Unicode. It does not make any difference whether the page is > coded in one or the other. (I'm working on WinXP, Java 1.6.0_31) > Past experience with javascript files says that they are assumed to > be in the same encoding as the html page. This being a JmolScript > file seems to not apply the same. > > Bob, I've put simple test pages at: > http://biomodel.uah.es/Jmol/UTF8/test-ISO.htm > http://biomodel.uah.es/Jmol/UTF8/test-UTF.htm > > > > > > ------------------------------------------------------------------------------ > Try before you buy = See our experts in action! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-dev2 > _______________________________________________ > Jmol-users mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-users > -- Robert M. Hanson Professor of Chemistry St. Olaf College 1520 St. Olaf Ave. Northfield, MN 55057 http://www.stolaf.edu/people/hansonr phone: 507-786-3107 If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 |
From: A. H. <ang...@ua...> - 2012-03-12 18:23:37
|
Thanks for your analysis, Bob I was quite sure that the saving is being done properly, but I know this a delicate ground, so I will look again. I've used Notepad++ because for sure I cannot trust my regular text editor, but Notepad++ seems to know how to save properly encoded files. And both js files are working fine. It's the spt (Jmolscript) UTF8 file the one that fails. > So your real problem, I think, is that your text editor is not saving > the text in UTF-8. You have to fix that first. Notepad, for instance, > has a UTF-8 save option. Then ó becomes <C3> <B3> in the file instead > of <F3>. that's almost certainly the problem. I will check those, thanks OK, I have checked them with an HEX editor now: test-ISO.js has F3 test-UTF.js has C3 B3 test-ISO.spt has F3 test-UTF.spt has C3 B3 So that is correct. Maybe something with the server, although I am seeing the same both local and from the server (the time when the server was not properly configured I did see differences between local and server) I will try another server. |
From: A. H. <ang...@ua...> - 2012-03-13 09:29:46
|
For anyone that's interested on this, I will summarise here my conclusions on this problem 1. In Windows, Java does not recognize the encoding of text files (e.g. JmolScript files) and loads them always in the system default encoding, Windows-1252. This is so for both Jmol application and Jmol applets. I guess that in other OSs the situation will be similar but with a different default (for instance, as far as I know MacOS used Unicode by default). By looking at the Java console (from the browser after an applet has been loaded) I see this report: Java console > press "s" (for dumping system properties) gives "file.encoding = Cp1252" (Which I understand as the Windows-1252 encoding) 2. How to force reading files as UTF-8? 2A. In the application, this can be done by invoking Jmol as: javaw -Xmx512m -Dfile.encoding=UTF8 -jar Jmol.jar (the -Xmx is optional and bears no relation with this problem; I just copied it from the standard jmol.bat) or enter this into a command line: set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 and then call the Jmol app normally: javaw -Xmx512m -jar Jmol.jar Possibly, if you add that "set" command into your system startup (autoexec.bat? or to system environment variables via the control panel), the setting will be default for any instance of the app. 2B. In the applet, go to "Control Panel > Java > Java tab > Configure Runtime Environment" and add the runtime parameter -Dfile.encoding=UTF8 After that, the applets will read files as UTF8 3. All of the above does not apply to Javascript files, which are interpreted by the browser according to whatever encoding is declared in the meta tag of the calling html file. So you can save a .JS text file as either UTF-8 (Unicode) or ISO8859-1 (Western European / ANSI / Roman / Latin) and it will work as long as the .html file is declared and saved in the same encoding. |
From: Robert H. <ha...@st...> - 2012-03-14 12:50:07
|
Angel, I found the real problem, I think. 1) If you are using UTF-8 characters, be sure to save any text files with UTF-8 encoding specified. This places a special 3-byte code at the front of the file that identifies it as UTF-8. This is critical. 2) If you are using UTF-8 characters in your .JS files or HTML, be sure to specify in your <head> block: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> Nothing else should be necessary. The problem was that Jmol was not recognizing the Binary Order Mark at the beginning of files. This was a bug. Jmol reads UTF-8 text natively, but was not considering the BOM \uFEFF at the beginning of the file (or anywhere else, for that matter). I've fixed that in Jmol 12.2.18 and 12.3.18 and will check in my changes later this morning. no need for -D switches. Bob Robert M. Hanson Professor of Chemistry St. Olaf College 1520 St. Olaf Ave. Northfield, MN 55057 http://www.stolaf.edu/people/hansonr phone: 507-786-3107 If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 |
From: Robert H. <ha...@st...> - 2012-03-14 17:06:27
|
OK, that's fixed. http://chemapps.stolaf.edu/jmol/docs/examples-12/Jmol-12.zip I'll also implement this in Jmol 12.2. It includes full support for UTF-16 as well. Bob On Wed, Mar 14, 2012 at 7:50 AM, Robert Hanson <ha...@st...> wrote: > Angel, I found the real problem, I think. > > 1) If you are using UTF-8 characters, be sure to save any text files with > UTF-8 encoding specified. This places a special 3-byte code at the front of > the file that identifies it as UTF-8. This is critical. > > 2) If you are using UTF-8 characters in your .JS files or HTML, be sure to > specify in your <head> block: > > <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> > > Nothing else should be necessary. The problem was that Jmol was not > recognizing the Binary Order Mark at the beginning of files. This was a > bug. Jmol reads UTF-8 text natively, but was not considering the BOM \uFEFF > at the beginning of the file (or anywhere else, for that matter). > > I've fixed that in Jmol 12.2.18 and 12.3.18 and will check in my changes > later this morning. > > no need for -D switches. > > Bob > > Robert M. Hanson > Professor of Chemistry > St. Olaf College > 1520 St. Olaf Ave. > Northfield, MN 55057 > http://www.stolaf.edu/people/hansonr > phone: 507-786-3107 > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > -- Robert M. Hanson Professor of Chemistry St. Olaf College 1520 St. Olaf Ave. Northfield, MN 55057 http://www.stolaf.edu/people/hansonr phone: 507-786-3107 If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 |
From: A. H. <ang...@ua...> - 2012-03-14 13:48:28
|
Bob, Good to hear that. > 1) If you are using UTF-8 characters, be sure to save any text files > with UTF-8 encoding specified. This places a special 3-byte code at > the front of the file that identifies it as UTF-8. This is critical. Up to now, all my tests including the BOM header caused problem, so I was not using it, and clearly Jmol had no means to guess the file coding. That sounds like the real solution. > 2) If you are using UTF-8 characters in your .JS files or HTML, be > sure to specify in your <head> block: > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" Yes, I was using that already. Thanks! |
From: A. H. <ang...@ua...> - 2012-03-16 17:17:29
|
Just confirming this is working fine for me now with the 12.3_dev version. Thanks, Bob El 14 Mar 2012 a las 12:06, Robert Hanson escribió: > OK, that's fixed. > http://chemapps.stolaf.edu/jmol/docs/examples-12/Jmol-12.zip |