sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * FUNCTION sl@0: * <>---transform string sl@0: * INDEX sl@0: * strxfrm sl@0: * ANSI_SYNOPSIS sl@0: * #include sl@0: * size_t strxfrm(char *<[s1]>, const char *<[s2]>, size_t <[n]>); sl@0: * TRAD_SYNOPSIS sl@0: * #include sl@0: * size_t strxfrm(<[s1]>, <[s2]>, <[n]>); sl@0: * char *<[s1]>; sl@0: * char *<[s2]>; sl@0: * size_t <[n]>; sl@0: * This function transforms the string pointed to by <[s2]> and sl@0: * places the resulting string into the array pointed to by sl@0: * <[s1]>. The transformation is such that if the <> sl@0: * function is applied to the two transformed strings, it returns sl@0: * a value greater than, equal to, or less than zero, sl@0: * correspoinding to the result of a <> function applied sl@0: * to the same two original strings. sl@0: * No more than <[n]> characters are placed into the resulting sl@0: * array pointed to by <[s1]>, including the terminating null sl@0: * character. If <[n]> is zero, <[s1]> may be a null pointer. If sl@0: * copying takes place between objects that overlap, the behavior sl@0: * is undefined. sl@0: * With a C locale, this function just copies. sl@0: * RETURNS sl@0: * The <> function returns the length of the transformed string sl@0: * (not including the terminating null character). If the value returned sl@0: * is <[n]> or more, the contents of the array pointed to by sl@0: * <[s1]> are indeterminate. sl@0: * PORTABILITY sl@0: * <> is ANSI C. sl@0: * <> requires no supporting OS subroutines. sl@0: * QUICKREF sl@0: * strxfrm ansi pure sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: sl@0: /** sl@0: Transform string using locale settings. sl@0: Copies the first num characters of src to dest performing the apropiate sl@0: transformations for the current locale settings if needed. sl@0: No null-character is implicitly appended to dest after copying process. sl@0: So dest may not be null-terminated if no null-caracters are copied from src. sl@0: If num is greater than the length of src, dest is padded with zeros until num. sl@0: The behavor of this function is the same as strncpy but performing locale sl@0: character transformations. sl@0: @return The length of the transformed string without the null-character terminator. sl@0: @param s1 Destination string. Space allocated should be at least num characters long. sl@0: @param s2 Null-terminated string containing string to be transformed. sl@0: @param n Number of characters to be transformed and stored in dest. sl@0: */ sl@0: EXPORT_C size_t sl@0: strxfrm (char *s1, const char *s2, size_t n) sl@0: { sl@0: size_t res; sl@0: res = 0; sl@0: while (n-- > 0 && *s2) sl@0: { sl@0: *s1++ = *s2++; sl@0: res++; sl@0: } sl@0: while (*s2) sl@0: { sl@0: s2++; sl@0: res++; sl@0: } sl@0: sl@0: return res; sl@0: }