Difference between revisions of "URL Basics"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
m
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The following information is based on material found in: <br> StarOffice™ 7 Office Suite <br> A Sun™ ONE Software Offering <br> Basic Programmer's Guide <br> Page 74. See http://docs.sun.com/app/docs/doc/817-1826?q=StarOffice.  
+
The following information is based on material found in: <br> StarOffice™ 7 Office Suite <br> A Sun™ ONE Software Offering <br> Basic Programmer's Guide on page 74.  
  
 +
=Filenames in URL Notation=
 +
Since {{AOo}} is a platform-independent application, it uses URL notation (which is independent of any operating system), as defined in the Internet Standard RFC 1738 for filenames. Standard filenames using this system begin with the prefix '''file:///''', followed by the local path. If the filename contains sub-directories, then these are separated by a single forward slash, not with a backslash usually used under Windows. The following path references the test.odt file in the doc directory on the C drive:
 +
<syntaxhighlight lang="oobas">
 +
file:///C:/doc/test.odt
 +
</syntaxhighlight>
  
=File Names in URL Notation=
+
To convert local filenames into an URL, {{AOo}} provides the <tt>ConvertToUrl</tt> function. To convert an URL into a local filename, {{AOo}} provides the <tt>ConvertFromUrl</tt> function:  
Since OpenOffice.org is a platform-independent application, it uses URL notation (which is independent of any operating system), as defined in the Internet Standard RFC 1738 for file names. Standard file names using this system begin with the prefix file:/// followed by the local path. If the file name contains sub-directories, then these are separated by a single forward slash., not with a backslash usually used under Windows. The following path references the test.sxw file in the doc directory on the C drive:.
+
  
<code>[oobas]
+
<syntaxhighlight lang="oobas">
file:///C:/doc/test.sxw
+
MsgBox ConvertToUrl("C:\doc\test.odt") ' supplies file:///C:/doc/test.odt
</code>
+
MsgBox ConvertFromUrl("file:///C:/doc/test.odt") ' supplies (under Windows) c:\doc\test.odt
To covert local file names into an URL, OpenOffice.org provides the ConvertToUrl function. To convert an URL into a local file name, OpenOffice.org provides the ConvertFromUrl function:
+
</syntaxhighlight>
 +
The example converts a local filename into a URL and displays it in a messagebox. It then converts a URL into a local filename and also displays this.  
  
<code>[oobas]
+
The Internet Standard RFC 1738, upon which this is based, permits use of the 0-9, a-z, and A-Z characters. All other characters are inserted as escape coding in the URLs. To do this, they are converted into their hexadecimal value in the ISO 8859-1 (ISO-Latin) set of characters and are preceded by a percent sign. For example, a space in a local filename therefore becomes a <tt>%20</tt> in the URL.
MsgBox ConvertToUrl("C:\doc\test.sxw") ' supplies file:///C:/doc/test.sxw
+
MsgBox ConvertFromUrl("file:///C:/doc/test.sxw") ' supplies (under Windows) c:\doc\test.sxw
+
</code>
+
The example converts a local file name into a URL and displays it in a message box. It then converts a URL into a local file name and also displays this.  
+
  
The Internet Standard RFC 1738, upon which this is based, permits use of the 0-9, a-z, and A-Z characters. All other characters are inserted as escape coding in the URLs. To do this, they are converted into their hexadecimal value in the ISO 8859-1 (ISO-Latin) set of characters and are preceded by a percent sign. A space in a local file name therefore, for example, becomes a %20 in the URL.
+
[[Category:Basic:Tutorials]]

Latest revision as of 16:15, 24 August 2022

The following information is based on material found in:
StarOffice™ 7 Office Suite
A Sun™ ONE Software Offering
Basic Programmer's Guide on page 74.

Filenames in URL Notation

Since Apache OpenOffice is a platform-independent application, it uses URL notation (which is independent of any operating system), as defined in the Internet Standard RFC 1738 for filenames. Standard filenames using this system begin with the prefix file:///, followed by the local path. If the filename contains sub-directories, then these are separated by a single forward slash, not with a backslash usually used under Windows. The following path references the test.odt file in the doc directory on the C drive:

 file:///C:/doc/test.odt

To convert local filenames into an URL, Apache OpenOffice provides the ConvertToUrl function. To convert an URL into a local filename, Apache OpenOffice provides the ConvertFromUrl function:

MsgBox ConvertToUrl("C:\doc\test.odt") ' supplies file:///C:/doc/test.odt
MsgBox ConvertFromUrl("file:///C:/doc/test.odt") ' supplies (under Windows) c:\doc\test.odt

The example converts a local filename into a URL and displays it in a messagebox. It then converts a URL into a local filename and also displays this.

The Internet Standard RFC 1738, upon which this is based, permits use of the 0-9, a-z, and A-Z characters. All other characters are inserted as escape coding in the URLs. To do this, they are converted into their hexadecimal value in the ISO 8859-1 (ISO-Latin) set of characters and are preceded by a percent sign. For example, a space in a local filename therefore becomes a %20 in the URL.

Personal tools