Blame doc/devhelp/libxml2-xmlstring.html

Packit Service a31ea6
Packit Service a31ea6
<html>
Packit Service a31ea6
  <head>
Packit Service a31ea6
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Packit Service a31ea6
    <title>xmlstring: set of routines to process strings</title>
Packit Service a31ea6
    <meta name="generator" content="Libxml2 devhelp stylesheet"/>
Packit Service a31ea6
    <link rel="start" href="index.html" title="libxml2 Reference Manual"/>
Packit Service a31ea6
    <link rel="up" href="general.html" title="API"/>
Packit Service a31ea6
    <link rel="stylesheet" href="style.css" type="text/css"/>
Packit Service a31ea6
    <link rel="chapter" href="general.html" title="API"/>
Packit Service a31ea6
  </head>
Packit Service a31ea6
  <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit Service a31ea6
    
Packit Service a31ea6
      
Packit Service a31ea6
        
Packit Service a31ea6
          
Packit Service a31ea6
            Prev
Packit Service a31ea6
          
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6
          
Packit Service a31ea6
            Up
Packit Service a31ea6
          
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6
          
Packit Service a31ea6
            Home
Packit Service a31ea6
          
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6
          
Packit Service a31ea6
            Next
Packit Service a31ea6
          
Packit Service a31ea6
        
Packit Service a31ea6
        libxml2 Reference Manual
Packit Service a31ea6
      
Packit Service a31ea6
    
Packit Service a31ea6
    

Packit Service a31ea6
      xmlstring
Packit Service a31ea6
    
Packit Service a31ea6
    

xmlstring - set of routines to process strings

Packit Service a31ea6
    

type and interfaces needed for the internal string handling of the library, especially UTF8 processing.

Packit Service a31ea6
    

Author(s): Daniel Veillard

Packit Service a31ea6
    
Packit Service a31ea6
      

Synopsis

Packit Service a31ea6
      
#define BAD_CAST;
Packit Service a31ea6
typedef unsigned char xmlChar;
Packit Service a31ea6
int	xmlStrcmp			(const xmlChar * str1, 
const xmlChar * str2);
Packit Service a31ea6
xmlChar *	xmlCharStrndup		(const char * cur, 
int len);
Packit Service a31ea6
const xmlChar *	xmlStrcasestr		(const xmlChar * str, 
const xmlChar * val);
Packit Service a31ea6
xmlChar *	xmlStrcat		(xmlChar * cur, 
const xmlChar * add);
Packit Service a31ea6
int	xmlStrPrintf			(xmlChar * buf, 
int len,
const char * msg,
... ...);
Packit Service a31ea6
const xmlChar *	xmlStrstr		(const xmlChar * str, 
const xmlChar * val);
Packit Service a31ea6
int	xmlUTF8Size			(const xmlChar * utf);
Packit Service a31ea6
int	xmlStrQEqual			(const xmlChar * pref, 
const xmlChar * name,
const xmlChar * str);
Packit Service a31ea6
xmlChar *	xmlStrncatNew		(const xmlChar * str1, 
const xmlChar * str2,
int len);
Packit Service a31ea6
const xmlChar *	xmlUTF8Strpos		(const xmlChar * utf, 
int pos);
Packit Service a31ea6
xmlChar *	xmlStrdup		(const xmlChar * cur);
Packit Service a31ea6
xmlChar *	xmlCharStrdup		(const char * cur);
Packit Service a31ea6
const xmlChar *	xmlStrchr		(const xmlChar * str, 
xmlChar val);
Packit Service a31ea6
int	xmlStrlen			(const xmlChar * str);
Packit Service a31ea6
int	xmlStrncmp			(const xmlChar * str1, 
const xmlChar * str2,
int len);
Packit Service a31ea6
xmlChar *	xmlStrsub		(const xmlChar * str, 
int start,
int len);
Packit Service a31ea6
xmlChar *	xmlStrncat		(xmlChar * cur, 
const xmlChar * add,
int len);
Packit Service a31ea6
int	xmlGetUTF8Char			(const unsigned char * utf, 
int * len);
Packit Service a31ea6
int	xmlStrcasecmp			(const xmlChar * str1, 
const xmlChar * str2);
Packit Service a31ea6
xmlChar *	xmlStrndup		(const xmlChar * cur, 
int len);
Packit Service a31ea6
int	xmlStrVPrintf			(xmlChar * buf, 
int len,
const char * msg,
va_list ap);
Packit Service a31ea6
int	xmlUTF8Strsize			(const xmlChar * utf, 
int len);
Packit Service a31ea6
int	xmlCheckUTF8			(const unsigned char * utf);
Packit Service a31ea6
int	xmlStrncasecmp			(const xmlChar * str1, 
const xmlChar * str2,
int len);
Packit Service a31ea6
int	xmlUTF8Strlen			(const xmlChar * utf);
Packit Service a31ea6
xmlChar *	xmlUTF8Strsub		(const xmlChar * utf, 
int start,
int len);
Packit Service a31ea6
int	xmlStrEqual			(const xmlChar * str1, 
const xmlChar * str2);
Packit Service a31ea6
int	xmlUTF8Charcmp			(const xmlChar * utf1, 
const xmlChar * utf2);
Packit Service a31ea6
xmlChar *	xmlUTF8Strndup		(const xmlChar * utf, 
int len);
Packit Service a31ea6
int	xmlUTF8Strloc			(const xmlChar * utf, 
const xmlChar * utfchar);
Packit Service a31ea6
Packit Service a31ea6
    
Packit Service a31ea6
    
Packit Service a31ea6
      

Description

Packit Service a31ea6
    
Packit Service a31ea6
    
Packit Service a31ea6
      

Details

Packit Service a31ea6
      
Packit Service a31ea6
        

Macro BAD_CAST

#define BAD_CAST;
Packit Service a31ea6

Macro to cast a string to an xmlChar * when one know its safe.

Packit Service a31ea6
Packit Service a31ea6
        
Packit Service a31ea6
        

Typedef xmlChar

unsigned char xmlChar;
Packit Service a31ea6

This is a basic byte in an UTF-8 encoded string. It's unsigned allowing to pinpoint case where char * are assigned to xmlChar * (possibly making serialization back impossible).

Packit Service a31ea6
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlCharStrdup ()

xmlChar *	xmlCharStrdup		(const char * cur)
Packit Service a31ea6

a strdup for char's to xmlChar's

Packit Service a31ea6
<tt>cur</tt>:the input char *
<tt>Returns</tt>:a new xmlChar * or NULL
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlCharStrndup ()

xmlChar *	xmlCharStrndup		(const char * cur, 
int len)
Packit Service a31ea6

a strndup for char's to xmlChar's

Packit Service a31ea6
<tt>cur</tt>:the input char *
<tt>len</tt>:the len of @cur
<tt>Returns</tt>:a new xmlChar * or NULL
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

Checks @utf for being valid UTF-8. @utf is assumed to be null-terminated. This function is not super-strict, as it will allow longer UTF-8 sequences than necessary. Note that Java is capable of producing these sequences if provoked. Also note, this routine checks for the 4-byte maximum size, but does not check for 0x10ffff maximum value.

Packit Service a31ea6
<tt>utf</tt>:Pointer to putative UTF-8 encoded string.
<tt>Returns</tt>:value: true if @utf is valid.
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

Read the first UTF8 character from @utf

Packit Service a31ea6
<tt>utf</tt>:a sequence of UTF-8 encoded bytes
<tt>len</tt>:a pointer to the minimum number of bytes present in the sequence. This is used to assure the next character is completely contained within the sequence.
<tt>Returns</tt>:the char value or -1 in case of error, and sets *len to the actual number of bytes consumed (0 in case of error)
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

Check if both strings are equal of have same content. Should be a bit more readable and faster than xmlStrcmp()

Packit Service a31ea6
<tt>str1</tt>:the first xmlChar *
<tt>str2</tt>:the second xmlChar *
<tt>Returns</tt>:1 if they are equal, 0 if they are different
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrPrintf ()

int	xmlStrPrintf			(xmlChar * buf, 
int len,
const char * msg,
... ...)
Packit Service a31ea6

Formats @msg and places result into @buf.

Packit Service a31ea6
<tt>buf</tt>:the result buffer.
<tt>len</tt>:the result buffer length.
<tt>msg</tt>:the message with printf formatting.
<tt>...</tt>:extra parameters for the message.
<tt>Returns</tt>:the number of characters written to @buf or -1 if an error occurs.
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

Check if a QName is Equal to a given string

Packit Service a31ea6
<tt>pref</tt>:the prefix of the QName
<tt>name</tt>:the localname of the QName
<tt>str</tt>:the second xmlChar *
<tt>Returns</tt>:1 if they are equal, 0 if they are different
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrVPrintf ()

int	xmlStrVPrintf			(xmlChar * buf, 
int len,
const char * msg,
va_list ap)
Packit Service a31ea6

Formats @msg and places result into @buf.

Packit Service a31ea6
<tt>buf</tt>:the result buffer.
<tt>len</tt>:the result buffer length.
<tt>msg</tt>:the message with printf formatting.
<tt>ap</tt>:extra parameters for the message.
<tt>Returns</tt>:the number of characters written to @buf or -1 if an error occurs.
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

a strcasecmp for xmlChar's

Packit Service a31ea6
<tt>str1</tt>:the first xmlChar *
<tt>str2</tt>:the second xmlChar *
<tt>Returns</tt>:the integer result of the comparison
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrcasestr ()

const xmlChar *	xmlStrcasestr		(const xmlChar * str, 
const xmlChar * val)
Packit Service a31ea6

a case-ignoring strstr for xmlChar's

Packit Service a31ea6
<tt>str</tt>:the xmlChar * array (haystack)
<tt>val</tt>:the xmlChar to search (needle)
<tt>Returns</tt>:the xmlChar * for the first occurrence or NULL.
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrcat ()

xmlChar *	xmlStrcat		(xmlChar * cur, 
const xmlChar * add)
Packit Service a31ea6

a strcat for array of xmlChar's. Since they are supposed to be encoded in UTF-8 or an encoding with 8bit based chars, we assume a termination mark of '0'.

Packit Service a31ea6
<tt>cur</tt>:the original xmlChar * array
<tt>add</tt>:the xmlChar * array added
<tt>Returns</tt>:a new xmlChar * containing the concatenated string. The original @cur is reallocated and should not be freed.
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrchr ()

const xmlChar *	xmlStrchr		(const xmlChar * str, 
xmlChar val)
Packit Service a31ea6

a strchr for xmlChar's

Packit Service a31ea6
<tt>str</tt>:the xmlChar * array
<tt>val</tt>:the xmlChar to search
<tt>Returns</tt>:the xmlChar * for the first occurrence or NULL.
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

a strcmp for xmlChar's

Packit Service a31ea6
<tt>str1</tt>:the first xmlChar *
<tt>str2</tt>:the second xmlChar *
<tt>Returns</tt>:the integer result of the comparison
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrdup ()

xmlChar *	xmlStrdup		(const xmlChar * cur)
Packit Service a31ea6

a strdup for array of xmlChar's. Since they are supposed to be encoded in UTF-8 or an encoding with 8bit based chars, we assume a termination mark of '0'.

Packit Service a31ea6
<tt>cur</tt>:the input xmlChar *
<tt>Returns</tt>:a new xmlChar * or NULL
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

length of a xmlChar's string

Packit Service a31ea6
<tt>str</tt>:the xmlChar * array
<tt>Returns</tt>:the number of xmlChar contained in the ARRAY.
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

a strncasecmp for xmlChar's

Packit Service a31ea6
<tt>str1</tt>:the first xmlChar *
<tt>str2</tt>:the second xmlChar *
<tt>len</tt>:the max comparison length
<tt>Returns</tt>:the integer result of the comparison
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrncat ()

xmlChar *	xmlStrncat		(xmlChar * cur, 
const xmlChar * add,
int len)
Packit Service a31ea6

a strncat for array of xmlChar's, it will extend @cur with the len first bytes of @add. Note that if @len < 0 then this is an API error and NULL will be returned.

Packit Service a31ea6
<tt>cur</tt>:the original xmlChar * array
<tt>add</tt>:the xmlChar * array added
<tt>len</tt>:the length of @add
<tt>Returns</tt>:a new xmlChar *, the original @cur is reallocated and should not be freed.
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrncatNew ()

xmlChar *	xmlStrncatNew		(const xmlChar * str1, 
const xmlChar * str2,
int len)
Packit Service a31ea6

same as xmlStrncat, but creates a new string. The original two strings are not freed. If @len is < 0 then the length will be calculated automatically.

Packit Service a31ea6
<tt>str1</tt>:first xmlChar string
<tt>str2</tt>:second xmlChar string
<tt>len</tt>:the len of @str2 or < 0
<tt>Returns</tt>:a new xmlChar * or NULL
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

a strncmp for xmlChar's

Packit Service a31ea6
<tt>str1</tt>:the first xmlChar *
<tt>str2</tt>:the second xmlChar *
<tt>len</tt>:the max comparison length
<tt>Returns</tt>:the integer result of the comparison
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrndup ()

xmlChar *	xmlStrndup		(const xmlChar * cur, 
int len)
Packit Service a31ea6

a strndup for array of xmlChar's

Packit Service a31ea6
<tt>cur</tt>:the input xmlChar *
<tt>len</tt>:the len of @cur
<tt>Returns</tt>:a new xmlChar * or NULL
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrstr ()

const xmlChar *	xmlStrstr		(const xmlChar * str, 
const xmlChar * val)
Packit Service a31ea6

a strstr for xmlChar's

Packit Service a31ea6
<tt>str</tt>:the xmlChar * array (haystack)
<tt>val</tt>:the xmlChar to search (needle)
<tt>Returns</tt>:the xmlChar * for the first occurrence or NULL.
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlStrsub ()

xmlChar *	xmlStrsub		(const xmlChar * str, 
int start,
int len)
Packit Service a31ea6

Extract a substring of a given string

Packit Service a31ea6
<tt>str</tt>:the xmlChar * array (haystack)
<tt>start</tt>:the index of the first char (zero based)
<tt>len</tt>:the length of the substring
<tt>Returns</tt>:the xmlChar * for the first occurrence or NULL.
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

compares the two UCS4 values

Packit Service a31ea6
<tt>utf1</tt>:pointer to first UTF8 char
<tt>utf2</tt>:pointer to second UTF8 char
<tt>Returns</tt>:result of the compare as with xmlStrncmp
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

calculates the internal size of a UTF8 character

Packit Service a31ea6
<tt>utf</tt>:pointer to the UTF8 character
<tt>Returns</tt>:the numbers of bytes in the character, -1 on format error
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

compute the length of an UTF8 string, it doesn't do a full UTF8 checking of the content of the string.

Packit Service a31ea6
<tt>utf</tt>:a sequence of UTF-8 encoded bytes
<tt>Returns</tt>:the number of characters in the string or -1 in case of error
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

a function to provide the relative location of a UTF8 char

Packit Service a31ea6
<tt>utf</tt>:the input UTF8 *
<tt>utfchar</tt>:the UTF8 character to be found
<tt>Returns</tt>:the relative character position of the desired char or -1 if not found
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlUTF8Strndup ()

xmlChar *	xmlUTF8Strndup		(const xmlChar * utf, 
int len)
Packit Service a31ea6

a strndup for array of UTF8's

Packit Service a31ea6
<tt>utf</tt>:the input UTF8 *
<tt>len</tt>:the len of @utf (in chars)
<tt>Returns</tt>:a new UTF8 * or NULL
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlUTF8Strpos ()

const xmlChar *	xmlUTF8Strpos		(const xmlChar * utf, 
int pos)
Packit Service a31ea6

a function to provide the equivalent of fetching a character from a string array

Packit Service a31ea6
<tt>utf</tt>:the input UTF8 *
<tt>pos</tt>:the position of the desired UTF8 char (in chars)
<tt>Returns</tt>:a pointer to the UTF8 character or NULL
Packit Service a31ea6
        
Packit Service a31ea6
        
Packit Service a31ea6

storage size of an UTF8 string the behaviour is not guaranteed if the input string is not UTF-8

Packit Service a31ea6
<tt>utf</tt>:a sequence of UTF-8 encoded bytes
<tt>len</tt>:the number of characters in the array
<tt>Returns</tt>:the storage size of the first 'len' characters of ARRAY
Packit Service a31ea6
        
Packit Service a31ea6
        

xmlUTF8Strsub ()

xmlChar *	xmlUTF8Strsub		(const xmlChar * utf, 
int start,
int len)
Packit Service a31ea6

Create a substring from a given UTF-8 string Note: positions are given in units of UTF-8 chars

Packit Service a31ea6
<tt>utf</tt>:a sequence of UTF-8 encoded bytes
<tt>start</tt>:relative pos of first char
<tt>len</tt>:total number to copy
<tt>Returns</tt>:a pointer to a newly created string or NULL if any problem
Packit Service a31ea6
        
Packit Service a31ea6
      
Packit Service a31ea6
    
Packit Service a31ea6
  </body>
Packit Service a31ea6
</html>