From b532dc82299d1a11b5bdbbbee17f614dd87e8307 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 16 Jun 2007 10:41:21 +0200 Subject: Replaced strncpy() and strn0cpy() with Utf8Strn0Cpy() where necessary --- tools.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'tools.c') diff --git a/tools.c b/tools.c index b44a4bb0..0faf1ea2 100644 --- a/tools.c +++ b/tools.c @@ -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; -- cgit v1.2.3