Changeset 449


Ignore:
Timestamp:
Sep 5, 2020, 7:17:44 PM (5 years ago)
Author:
pr
Message:

Add BSUString copy constructor for codepaged C strings.
Substitute "(C)" for copyright symbol on unsupported codepages.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/cppbase/bs_string.h

    r421 r449  
    2323
    2424/*
    25  *      This file Copyright (C) 1999-2015 Ulrich M”ller.
     25 *      This file Copyright (C) 1999-2020 Ulrich M”ller.
    2626 *      This program is free software; you can redistribute it and/or modify
    2727 *      it under the terms of the GNU General Public License as published by
     
    910910            BSUString(BSUniCodec *pCodec,
    911911                      const BSString &str);
     912            BSUString(BSUniCodec *pCodec,
     913                      const char *psz);
    912914
    913915            /********************************************
  • trunk/src/cppbase/bs_string.cpp

    r421 r449  
    366366
    367367/*
    368  *@@ appendCP:
     368 *@@ appendUtf8:
    369369 *      assigns the given UTF-8 BSUString to this,
    370370 *      using the specified BSUniCodec for conversion
  • trunk/src/cppbase/bs_string_conv.cpp

    r370 r449  
    4848#pragma hdrstop
    4949
    50 #define CP_UTF8         1208
     50#define CP_UTF8         1208
     51#define UNI_COPYRIGHT   0xA9
    5152
    5253DEFINE_CLASS(BSUniCodec, BSRoot);
     
    255256 *
    256257 *@@changed WarpIN V1.0.18 (2008-09-24) [pr]: added codepage 1208 support @@fixes 1127
     258 *@@changed WarpIN V1.0.25 (2020-09-05) [pr]: added copyright symbol substitution
    257259 */
    258260
     
    282284        {
    283285            if (us == 0xFFFF)
    284                 us = '?';
     286                if (ulUni == UNI_COPYRIGHT)
     287                {
     288                    xstrcat(&xstrNew, "(C)", 3);
     289                    continue;
     290                }
     291                else
     292                    us = '?';
    285293            else if (_fDouble)
    286294            {
  • trunk/src/cppbase/bs_string_uni.cpp

    r254 r449  
    99
    1010/*
    11  *      This file Copyright (C) 2002 Ulrich M”ller.
     11 *      This file Copyright (C) 2020 Ulrich M”ller.
    1212 *      This program is free software; you can redistribute it and/or modify
    1313 *      it under the terms of the GNU General Public License as published by
     
    104104
    105105/*
     106 *@@ BSUString:
     107 *      copy constructor to convert from a
     108 *      codepaged C string, using the
     109 *      specified BSUniCodec for conversion.
     110 *
     111 *@@added WarpIN V1.0.25 (2020-09-05) [pr]
     112 */
     113
     114BSUString::BSUString(BSUniCodec *pCodec,
     115                     const char *psz)
     116    : BSStringBase(tBSUString)
     117{
     118    STRINGLOCK;
     119
     120    if (!pCodec)
     121        throw BSExcptBase("pCodec is NULL.");
     122
     123    size_type st;
     124    if (st = strlen(psz))
     125    {
     126        pCodec->Codepage2Uni(*this,
     127                             psz,
     128                             st);
     129    }
     130}
     131
     132/*
    106133 *@@ operator[]:
    107134 *      returns the ul'th character of the
     
    235262    FreeBuf();
    236263
     264    if (!pCodec)
     265        throw BSExcptBase("pCodec is NULL.");
     266
    237267    size_type st;
    238268    if (st = strlen(psz))
Note: See TracChangeset for help on using the changeset viewer.