.TH "unicode.c" 3 "Version 1.1.21" "libmtp" \" -*- nroff -*- .ad l .nh .SH NAME libmtp \- .SH SYNOPSIS .br .PP \fC#include 'config\&.h'\fP .br \fC#include \fP .br \fC#include \fP .br \fC#include 'libmtp\&.h'\fP .br \fC#include 'unicode\&.h'\fP .br \fC#include 'util\&.h'\fP .br \fC#include 'ptp\&.h'\fP .br .SS "Macros" .in +1c .ti -1c .RI "#define \fBSTRING_BUFFER_LENGTH\fP 1024" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "int \fBucs2_strlen\fP (uint16_t const *const unicstr)" .br .ti -1c .RI "char * \fButf16_to_utf8\fP (\fBLIBMTP_mtpdevice_t\fP *device, const uint16_t *unicstr)" .br .ti -1c .RI "uint16_t * \fButf8_to_utf16\fP (\fBLIBMTP_mtpdevice_t\fP *device, const char *localstr)" .br .ti -1c .RI "void \fBstrip_7bit_from_utf8\fP (char *str)" .br .in -1c .SH "Detailed Description" .PP This file contains general Unicode string manipulation functions\&. It mainly consist of functions for converting between UCS-2 (used on the devices) and UTF-8 (used by several applications)\&. .PP For a deeper understanding of Unicode encoding formats see the Wikipedia entries for \fCUTF-16/UCS-2\fP and \fCUTF-8\fP\&. .PP Copyright (C) 2005-2009 Linus Walleij triad@df.lth.se .PP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version\&. .PP This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\&. See the GNU Lesser General Public License for more details\&. .PP You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc\&., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA\&. .SH "Macro Definition Documentation" .PP .SS "#define STRING_BUFFER_LENGTH 1024" The size of the buffer (in characters) used for creating string copies\&. .SH "Function Documentation" .PP .SS "void strip_7bit_from_utf8 (char * str)" This helper function simply removes any consecutive chars .PP .RS 4 0x7F and replace then with an underscore\&. In UTF-8 .RE .PP consecutive chars > 0x7F represent one single character so it has to be done like this (and it's elegant)\&. It will only shrink the string in size so no copying is needed\&. .PP Referenced by \fBLIBMTP_Create_Folder()\fP\&. .SS "int ucs2_strlen (uint16_t const *const unicstr)" Gets the length (in characters, not bytes) of a unicode UCS-2 string, eg a string which physically is 0x00 0x41 0x00 0x00 will return a value of 1\&. .PP \fBParameters\fP .RS 4 \fIunicstr\fP a UCS-2 Unicode string .RE .PP \fBReturns\fP .RS 4 the length of the string, in number of characters\&. If you want to know the length in bytes, multiply this by two and add two (for zero terminator)\&. .RE .PP .PP Referenced by \fButf16_to_utf8()\fP, and \fButf8_to_utf16()\fP\&. .SS "char * utf16_to_utf8 (\fBLIBMTP_mtpdevice_t\fP * device, const uint16_t * unicstr)" Converts a big-endian UTF-16 2-byte string to a UTF-8 string\&. Actually just a UCS-2 internal conversion routine that strips off the BOM if there is one\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the current device\&. .br \fIunicstr\fP the UTF-16 unicode string to convert .RE .PP \fBReturns\fP .RS 4 a UTF-8 string\&. .RE .PP .PP References \fBLIBMTP_mtpdevice_struct::params\fP, \fBSTRING_BUFFER_LENGTH\fP, and \fBucs2_strlen()\fP\&. .SS "uint16_t * utf8_to_utf16 (\fBLIBMTP_mtpdevice_t\fP * device, const char * localstr)" Converts a UTF-8 string to a big-endian UTF-16 2-byte string Actually just a UCS-2 internal conversion\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the current device\&. .br \fIlocalstr\fP the UTF-8 unicode string to convert .RE .PP \fBReturns\fP .RS 4 a UTF-16 string\&. .RE .PP .PP References \fBLIBMTP_mtpdevice_struct::params\fP, \fBSTRING_BUFFER_LENGTH\fP, and \fBucs2_strlen()\fP\&. .SH "Author" .PP Generated automatically by Doxygen for libmtp from the source code\&.