Made to Order Software Corporation Logo

LLChatLib: /home/doug/src/oss/slitechat/trunk/LLChatLib/llcommon/llstring.cpp File Reference

/home/doug/src/oss/slitechat/trunk/LLChatLib/llcommon/llstring.cpp File Reference

String utility functions and the std::string class. More...

#include "linden_common.h"
#include "llstring.h"
#include "llerror.h"
Include dependency graph for llstring.cpp:

Namespaces

namespace  LLStringFn

Functions

bool _read_file_into_string (std::string &str, const std::string &filename)
 read the contents of a file into a string.

U8 hex_as_nybble (char hex)
 This translates a nybble stored as a hex value from 0-f back to a nybble in the low order bits of the return byte.

std::string ll_safe_string (const char *in)
 Return a string constructed from in without crashing if the pointer is NULL.

std::string rawstr_to_utf8 (const std::string &raw)
void LLStringFn::replace_ascii_controlchars (std::basic_string< char > &string, char replacement)
 Replace all control characters (c < 0x20) with replacement in string.

void LLStringFn::replace_nonprintable_and_pipe_in_ascii (std::basic_string< char > &str, char replacement)
 Replace all non-printable characters and pipe characters with replacement in a string. NOTE - this will zap non-ascii.

void LLStringFn::replace_nonprintable_in_ascii (std::basic_string< char > &string, char replacement)
 Replace all non-printable characters with replacement in string. NOTE - this will zap non-ascii.

std::string LLStringFn::strip_invalid_xml (const std::string &input)
 Remove all characters that are not allowed in XML 1.0. Returns a copy of the string with those characters removed. Works with US ASCII and UTF-8 encoded strings. JC.

std::string utf8str_substChar (const std::string &utf8str, const llwchar target_char, const llwchar replace_char)
 Replace all occurences of target_char with replace_char.

std::string utf8str_truncate (const std::string &utf8str, const S32 max_len)
 Properly truncate a utf8 string to a maximum byte count.


Detailed Description

String utility functions and the std::string class.

LicenseInfo
firstyear=2001&license=viewergpl

Copyright (c) 2001-2009, Linden Research, Inc.

Second Life Viewer Source Code The source code in this file ("Source Code") is provided by Linden Lab to you under the terms of the GNU General Public License, version 2.0 ("GPL"), unless you have obtained a separate licensing agreement ("Other License"), formally executed by you and Linden Lab. Terms of the GPL can be found in doc/GPL-license.txt in this distribution, or online at http://secondlifegrid.net/programs/open_source/licensing/gplv2

There are special exceptions to the terms and conditions of the GPL as it is applied to this Source Code. View the full text of the exception in the file doc/FLOSS-exception.txt in this software distribution, or online at http://secondlifegrid.net/programs/open_source/licensing/flossexception

By copying, modifying or distributing this software, you acknowledge that you have read and understood your obligations described above, and agree to abide by those obligations.

ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, COMPLETENESS OR PERFORMANCE. $/LicenseInfo$


Function Documentation

bool _read_file_into_string ( std::string &  str,
const std::string &  filename 
)

read the contents of a file into a string.

Since this function has no concept of character encoding, most anything you do with this method ill-advised. Please avoid.

Parameters:
str [out] The string which will have.
filename The full name of the file to read.
Returns:
Returns true on success. If false, str is unmodified.
std::string rawstr_to_utf8 ( const std::string &  raw  ) 

Unicode support

std::string utf8str_substChar ( const std::string &  utf8str,
const llwchar  target_char,
const llwchar  replace_char 
)

Replace all occurences of target_char with replace_char.

Parameters:
utf8str A utf8 string to process.
target_char The wchar to be replaced
replace_char The wchar which is written on replace
std::string utf8str_truncate ( const std::string &  utf8str,
const S32  max_len 
)

Properly truncate a utf8 string to a maximum byte count.

The returned string may be less than max_len if the truncation happens in the middle of a glyph. If max_len is longer than the string passed in, the return value == utf8str.

Parameters:
utf8str A valid utf8 string to truncate.
max_len The maximum number of bytes in the return value.
Returns:
Returns a valid utf8 string with byte count <= max_len.



Generated on Thu Sep 23 17:16:02 2010 for LLChatLib by  doxygen 1.6.3