diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2007-06-16 10:41:21 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2007-06-16 10:41:21 +0200 |
commit | b532dc82299d1a11b5bdbbbee17f614dd87e8307 (patch) | |
tree | 26e67a6b9f0ef901f7df1e2213b9deb450aea40c /tools.c | |
parent | 81e44bce198d53d0515290724c0ec8f989b9e01d (diff) | |
download | vdr-b532dc82299d1a11b5bdbbbee17f614dd87e8307.tar.gz vdr-b532dc82299d1a11b5bdbbbee17f614dd87e8307.tar.bz2 |
Replaced strncpy() and strn0cpy() with Utf8Strn0Cpy() where necessary
Diffstat (limited to 'tools.c')
-rw-r--r-- | tools.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.127 2007/06/16 09:05:11 kls Exp $ + * $Id: tools.c 1.128 2007/06/16 09:22:40 kls Exp $ */ #include "tools.h" @@ -661,6 +661,25 @@ int Utf8StrLen(const char *s) return n; } +char *Utf8Strn0Cpy(char *Dest, const char *Src, int n) +{ + if (cCharSetConv::SystemCharacterTable()) + return strn0cpy(Dest, Src, n); + char *d = Dest; + while (*Src) { + int sl = Utf8CharLen(Src); + n -= sl; + if (n > 0) { + while (sl--) + *d++ = *Src++; + } + else + break; + } + *d = 0; + return Dest; +} + int Utf8ToArray(const char *s, uint *a, int Size) { int n = 0; |