Main Page | Class List | File List | Class Members | File Members

ipod_string.h File Reference

String manipulation functions. More...

#include <sys/types.h>

Go to the source code of this file.

Functions

char * ipod_string_new (void)
 Allocates a new zero-terminated string on the heap.
char * ipod_string_new_from (const char *s)
 Allocates a new zero-terminated string on the heap copied from the given string.
char * ipod_string_new_from_array (const char *s, size_t length)
 Allocates a new string on the heap created from an array of characters.
char * ipod_string_set (char *s, const char *ss)
 Copy a string into an exising allocated string, resizing as necessary.
void ipod_string_free (char *s)
 Free the string back to the heap.
char * ipod_string_zero (char *s)
 Resize an existing string to an empty string.
char * ipod_string_realloc (char *src, size_t length)
 Reallocate an existing string to hold the given length, plus the terminating null.
char * ipod_string_append (char *src, const char *a)
 Append a string to an existing string.
void ipod_string_replace_char (char *src, const char a, const char b)
 Destructively replace all instances of a with b in an existing string.
size_t ipod_string_utf16_to_utf8_length (const char *src, size_t numChars)
 Calculate the number of bytes necessary for a UTF-8 encoding of an array of UTF-16LE characters.
size_t ipod_string_utf16_to_utf8 (const char *src, size_t numChars, char *dst, size_t maxLen)
 Convert an array of UTF-16LE characters to UTF-8.
size_t ipod_string_utf8_to_utf16_length (const char *s)
 Calculate the number of UTF-16LE characters in a null terminated UTF-8 string.
size_t ipod_string_utf8_to_utf16 (const char *src, char *dst, size_t maxLen)
 Convert a string of UTF-8 characters into an array of UTF-16LE characters.
char * ipod_string_utf8_from_utf16 (const char *src, size_t numChars)
 Convert an array of UTF-16LE characters to a UTF-8 string allocated on the heap.
char * ipod_string_utf16_from_utf8 (const char *src, size_t *numChars)
 Convert a UTF-8 encoded string to an array of UTF-16LE characters allocated on the heap.
char * ipod_string_utf16_from_iso8859 (const char *src, size_t *numChars)
 Convert an ISO-8859-1 encoded string to an array of UTF-16LE characters allocated on the heap.
char * ipod_string_iso8859_from_utf16 (const char *src, size_t numChars)
 Convert an array of UTF-16LE characters to an ISO-8859-1 string allocated on the heap.
char * ipod_string_utf8_from_iso8859 (const char *src)
 Convert a string of ISO-8859-1 characters to UTF-8.
char * ipod_string_iso8859_from_utf8 (const char *src)
 Convert a string of UTF-8 characters to ISO-8859-1.
int ipod_string_compare_utf16 (const char *a, size_t numCharsA, const char *b, size_t numCharsB)
 Compare two arrays of UTF-16LE characters.
void ipod_string_report (void)
 Print out some internal statistics.


Detailed Description

String manipulation functions.

The iPod data structures store text in a variety of formats. The bulk of the text items are stored in UTF-16LE, but some are in either ASCII or UTF-8. The libipod API normalizes all of them to UTF-8, although the C++ binding will also support ISO-8859-1.


Function Documentation

char* ipod_string_append char *  src,
const char *  a
 

Append a string to an existing string.

Parameters:
src the string to wich to append
a the string to append
Returns:
the reallocated string

int ipod_string_compare_utf16 const char *  a,
size_t  numCharsA,
const char *  b,
size_t  numCharsB
 

Compare two arrays of UTF-16LE characters.

Parameters:
a a pointer to an array of UTF-16LE characters
numCharsA the number of characters in 'a'
b a pointer to an array of UTF-16LE characters
numCharsB the number of characters in 'b'
Returns:
-1 if a < b, 0 if a==b, 1 if a > b

void ipod_string_free char *  s  ) 
 

Free the string back to the heap.

Parameters:
s the string to free

char* ipod_string_iso8859_from_utf16 const char *  src,
size_t  numChars
 

Convert an array of UTF-16LE characters to an ISO-8859-1 string allocated on the heap.

Parameters:
src pointer to an array of UTF-16LE characters
numChars the number of characters in the UTF-16LE array
Returns:
a null-terminated string containing the ISO-8859-1 characters

char* ipod_string_iso8859_from_utf8 const char *  src  ) 
 

Convert a string of UTF-8 characters to ISO-8859-1.

Parameters:
src a string of UTF-8 characters
Returns:
a string of ISO-8859-1 characters allocated on the heap

char* ipod_string_new void   ) 
 

Allocates a new zero-terminated string on the heap.

Returns:
pointer to a single zero byte on the heap

char* ipod_string_new_from const char *  s  ) 
 

Allocates a new zero-terminated string on the heap copied from the given string.

Parameters:
s the string to copy
Returns:
pointer to the new string

char* ipod_string_new_from_array const char *  s,
size_t  length
 

Allocates a new string on the heap created from an array of characters.

Parameters:
s a pointer to an array of characters
length the number of characters in the array
Returns:
pointer to the new string

char* ipod_string_realloc char *  src,
size_t  length
 

Reallocate an existing string to hold the given length, plus the terminating null.

Parameters:
src the string to resize
length the new lenght for the string
Returns:
the reallocated string

void ipod_string_replace_char char *  src,
const char  a,
const char  b
 

Destructively replace all instances of a with b in an existing string.

Parameters:
src the strin to modify
a the character to replace
b the character with which to replace

char* ipod_string_set char *  s,
const char *  ss
 

Copy a string into an exising allocated string, resizing as necessary.

Parameters:
s the string to copy into
ss the string to copy from
Returns:
the reallocated string

char* ipod_string_utf16_from_iso8859 const char *  src,
size_t *  numChars
 

Convert an ISO-8859-1 encoded string to an array of UTF-16LE characters allocated on the heap.

Parameters:
src the null terminated string of ISO-8859-1 characters
numChars a pointer to location to store the number of characters in the array of UTF-16LE characters
Returns:
a pointer to the array of UTF-16LE characters on the heap

char* ipod_string_utf16_from_utf8 const char *  src,
size_t *  numChars
 

Convert a UTF-8 encoded string to an array of UTF-16LE characters allocated on the heap.

Parameters:
src the null terminated string of UTF-8 characters
numChars a pointer to location to store the number of characters in the array of UTF-16LE characters
Returns:
a pointer to the array of UTF-16LE characters on the heap

size_t ipod_string_utf16_to_utf8 const char *  src,
size_t  numChars,
char *  dst,
size_t  maxLen
 

Convert an array of UTF-16LE characters to UTF-8.

Parameters:
src pointer to the array of UTF-16LE characters
numChars the number of characters in the UTF-16BE array
dst pointer to the buffer to stored the converted characters
maxLen the maximum number of bytes to store in the destination buffer
Returns:
the number of bytes stored in the destination buffer

size_t ipod_string_utf16_to_utf8_length const char *  src,
size_t  numChars
 

Calculate the number of bytes necessary for a UTF-8 encoding of an array of UTF-16LE characters.

Parameters:
src pointer to the array of UTF-16LE characters
numChars the number of characters in the UTF-16BE array
Returns:
the number of bytes needed to represent the array in UTF-8

char* ipod_string_utf8_from_iso8859 const char *  src  ) 
 

Convert a string of ISO-8859-1 characters to UTF-8.

Parameters:
src a string of UTF-8 characters
Returns:
a string of ISO-8859-1 characters allocated on the heap

char* ipod_string_utf8_from_utf16 const char *  src,
size_t  numChars
 

Convert an array of UTF-16LE characters to a UTF-8 string allocated on the heap.

Parameters:
src pointer to an array of UTF-16LE characters
numChars the number of characters in the UTF-16LE array
Returns:
a null-terminated string containing the UTF-8 characters

size_t ipod_string_utf8_to_utf16 const char *  src,
char *  dst,
size_t  maxLen
 

Convert a string of UTF-8 characters into an array of UTF-16LE characters.

Parameters:
src pointer to string or UTF-8 characters
dst pointer to buffer in which to store the UTF-16LE characters
maxLen the maximum number of UTF-16LE characters to store
Returns:
the number of UTF-16LE characters converted

size_t ipod_string_utf8_to_utf16_length const char *  s  ) 
 

Calculate the number of UTF-16LE characters in a null terminated UTF-8 string.

Parameters:
s a pointer to a null-terminated UTF-8 string
Returns:
the number of UTF-16LE characters needed to store the string

char* ipod_string_zero char *  s  ) 
 

Resize an existing string to an empty string.

Parameters:
s the string to empty
Returns:
the reallocated string


Generated on Tue Dec 13 14:55:22 2005 for libipod by  doxygen 1.3.9.1