File:  [Public] / libwww / Library / src / HTEscape.html
Revision 2.17: download - view: text, annotated - select for diffs
Sun May 24 23:03:13 1998 UTC (26 years ago) by frystyk
Branches: MAIN
CVS tags: repeat-requests, before_webdav, Release-5-4-0, Release-5-3-1, Release-5-2-8, Release-5-2-6, Release-5-2, Release-5-1m, HEAD, Before-New-Trace-Messages, Amaya_2_4, Amaya-6-3, Amaya-6-1, Amaya-5-2, Amaya-4-3-2, Amaya-4-3-1, Amaya-4-3, Amaya-4-1-2, Amaya-4-1-0, Amaya-4-0-0, Amaya-3-2-1, Amaya-3-2, Amaya
Changed HTEscape to deal with Dos files escaping

<HTML>
<HEAD>
  <TITLE>W3C Sample Code Library libwww URIs</TITLE>
</HEAD>
<BODY>
<H1>
  Escape and Unescape Illegal Characters in URIs
</H1>
<PRE>
/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
</PRE>
<P>
URLs are written only with the graphic printable characters of the US-ASCII
coded character set. All other characters must be escaped before they can
be used in URLs. This module defines the methods required for escaping and
unescaping the URLs. Internally in the Library, all URLs are escaped so that
we never see illegal characters in the URL handled by the Library. We only
unescape the URLs when we have to, for example while taking to the local
file system etc.
<P>
This module is implemented by <A HREF="HTEscape.c">HTEscape.c</A>, and it
is a part of the <A HREF="http://www.w3.org/Library/"> W3C Sample Code
Library</A>.
<PRE>
#ifndef HTESCAPE_H
#define HTESCAPE_H

</PRE>
<H2>
  Encode Unacceptable Characters using %xy
</H2>
<P>
This function takes a string containing any sequence of ASCII characters,
and returns a malloced string containing the same infromation but with all
"unacceptable" characters represented in the form <CODE>%xy</CODE> where
<CODE>x</CODE> and <CODE>y</CODE> are two hex digits.
<PRE>
typedef enum _HTURIEncoding {
    URL_XALPHAS		= 0x1,     /* Escape all unsafe characters */
    URL_XPALPHAS	= 0x2,     /* As URL_XALPHAS but allows '+' */
    URL_PATH		= 0x4,     /* As URL_XPALPHAS but allows '/' */
    URL_DOSFILE         = 0x8      /* As URL_URLPATH but allows ':' */
} HTURIEncoding;

extern char * HTEscape (const char * str, HTURIEncoding mask);
</PRE>

<H2>
  Convert a single Character from Ascii Hex to Char
</H2>

<PRE>
extern char HTAsciiHexToChar (char c);
</PRE>

<H2>
  Decode %xy Escaped Characters
</H2>
<P>
This function takes a pointer to a string in which character smay have been
encoded in <CODE>%xy</CODE> form, where <CODE>xy</CODE> is the acsii hex
code for character 16x+y. The string is converted in place, as it will never
grow.
<PRE>
extern char * HTUnEscape (char * str);
</PRE>
<PRE>
#endif	/* HTESCAPE_H */
</PRE>
<P>
  <HR>
<ADDRESS>
  @(#) $Id: HTEscape.html,v 2.17 1998/05/24 23:03:13 frystyk Exp $
</ADDRESS>
</BODY></HTML>

Webmaster