[{"id":12006,"web_url":"https://patchwork.libcamera.org/comment/12006/","msgid":"<6328991c-5d43-ee18-9cff-df7b2e794203@ideasonboard.com>","date":"2020-08-14T08:28:59","subject":"Re: [libcamera-devel] [PATCH v4 2/7] libcamera: utils: Add method\n\tto strip Unicode characters","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Niklas,\n\nOn 13/08/2020 23:37, Niklas Söderlund wrote:\n> Add method that strips non-ASCII characters from a string.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nI still would have thought the isprint might be more useful, as I don't\nthink we want chars like newlines/or console control characthers getting\nthrough these strings.\n\nBut if you don't think that's an issue here:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nI don't want to block the series, and this is an internal helper so it\ncan always be updated if we hit any issue.\n\n\n\n> ---\n> * Changes since v3\n> - Fix spelling in comment.\n> - Rename to toAscii()\n> ---\n>  include/libcamera/internal/utils.h |  2 ++\n>  src/libcamera/utils.cpp            | 21 +++++++++++++++++++++\n>  2 files changed, 23 insertions(+)\n> \n> diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\n> index 45cd6f120c51586b..b27f5a2323552058 100644\n> --- a/include/libcamera/internal/utils.h\n> +++ b/include/libcamera/internal/utils.h\n> @@ -197,6 +197,8 @@ private:\n>  \n>  details::StringSplitter split(const std::string &str, const std::string &delim);\n>  \n> +std::string toAscii(const std::string &str);\n> +\n>  std::string libcameraBuildPath();\n>  std::string libcameraSourcePath();\n>  \n> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> index 615df46ac142a2a9..726b84bfbae53ff2 100644\n> --- a/src/libcamera/utils.cpp\n> +++ b/src/libcamera/utils.cpp\n> @@ -342,6 +342,27 @@ details::StringSplitter split(const std::string &str, const std::string &delim)\n>  \treturn details::StringSplitter(str, delim);\n>  }\n>  \n> +/**\n> + * \\brief Strip all Unicode characters from a string\n> + * \\param[in] str The string to strip\n> + *\n> + * Strip all non-ASCII characters form a string. A Unicode character that spans\n> + * multiple bytes (and therefore is not also an ASCII character) may be\n> + * identified by the fact that its most significant bit is always set.\n> + *\n> + * \\todo When switching to C++ 20 use std::remove_if.\n> + *\n> + * \\return An ASCII string\n> + */\n> +std::string toAscii(const std::string &str)\n> +{\n> +\tstd::string ret;\n> +\tfor (const char &c : str)\n> +\t\tif (!(c & 0x80))\n> +\t\t\tret += c;\n> +\treturn ret;\n> +}\n> +\n>  /**\n>   * \\brief Check if libcamera is installed or not\n>   *\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 93ADFBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Aug 2020 08:29:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EB934613C0;\n\tFri, 14 Aug 2020 10:29:04 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D10960386\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Aug 2020 10:29:04 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C336E331;\n\tFri, 14 Aug 2020 10:29:02 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Or5TL1fi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1597393742;\n\tbh=XVybYpHNumHQmrxXzXkYpxwOPZLjpF3DfG+TsQVulFo=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=Or5TL1fiHieiPImZj0vPOLpwo1FD1dY/cAENnP4pbKvmc0JrEeOq6wxbl4Vo5FukS\n\tj1UDyEmNpbLZ4e9OrBYTwFCIp2usDbSAzzHZ7delxJwj0uI6qbXonXCAZ20MmRRo13\n\t4RWYh1fuVjKt89Pdi49QOUDSbHD1dz9Xr+aZT1NM=","To":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20200813223722.4050835-1-niklas.soderlund@ragnatech.se>\n\t<20200813223722.4050835-3-niklas.soderlund@ragnatech.se>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf\n\tKr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+zo+Y/OBd+8Ptgt1pDRyOBzL8\n\tRXa8ZqRf0Mwg75D+dKntZeJHzPRJyrlfQokngAAs4PaFt6UfS+ypMAF37T6CeDArQ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Ax3sOVFhk4WQaKRshCB7cSl+RIng5S/ThOBlwNlcKG7j7W2MC06BlTbdEkUp\n\tECzuuRBv8wX4OQl+hbWbB/VKIx5HKlLu1eypen/5lNVzSqMMIYkkZcjV2SWQyUGxSwq0O/sx\n\tS0A8/atCHUXOboUsn54qdxrVDaK+6jIAuo8JiRWctP16KjzUM7MO0/+4zllM8EY57rXrj48j\n\tsbEYX0YQnzaj+jO6kJtoZsIaYR7rMMq9aUAjyiaEZpmP1qF/2sYenDx0Fg2BSlLvLvXM0vU8\n\tpQk3kgDu7kb/7PRYrZvBsr21EIQoIjXbZxDz/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc\n\tMW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU\n\tAfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<6328991c-5d43-ee18-9cff-df7b2e794203@ideasonboard.com>","Date":"Fri, 14 Aug 2020 09:28:59 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<20200813223722.4050835-3-niklas.soderlund@ragnatech.se>","Content-Language":"en-GB","Subject":"Re: [libcamera-devel] [PATCH v4 2/7] libcamera: utils: Add method\n\tto strip Unicode characters","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Reply-To":"kieran.bingham@ideasonboard.com","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":12016,"web_url":"https://patchwork.libcamera.org/comment/12016/","msgid":"<20200814104245.GC1995759@oden.dyn.berto.se>","date":"2020-08-14T10:42:45","subject":"Re: [libcamera-devel] [PATCH v4 2/7] libcamera: utils: Add method\n\tto strip Unicode characters","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Kieran,\n\nOn 2020-08-14 09:28:59 +0100, Kieran Bingham wrote:\n> Hi Niklas,\n> \n> On 13/08/2020 23:37, Niklas Söderlund wrote:\n> > Add method that strips non-ASCII characters from a string.\n> > \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> \n> I still would have thought the isprint might be more useful, as I don't\n> think we want chars like newlines/or console control characthers getting\n> through these strings.\n\nI thought about it but if we used std::isprint() this would not produce \nan ASCII string, instead it would produce an printable string :-) I read \nsome post (which I can't find now) that spoke agains using \nstd::isprint() to drop non-ASCII charters, but it might have been \ntargeted on proprietary OS implementations...\n\nAs you say, this is an internal helper and we can switch to \nstd::isprint() later if need.\n\n> \n> But if you don't think that's an issue here:\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nThanks!\n\n> \n> I don't want to block the series, and this is an internal helper so it\n> can always be updated if we hit any issue.\n> \n> \n> \n> > ---\n> > * Changes since v3\n> > - Fix spelling in comment.\n> > - Rename to toAscii()\n> > ---\n> >  include/libcamera/internal/utils.h |  2 ++\n> >  src/libcamera/utils.cpp            | 21 +++++++++++++++++++++\n> >  2 files changed, 23 insertions(+)\n> > \n> > diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\n> > index 45cd6f120c51586b..b27f5a2323552058 100644\n> > --- a/include/libcamera/internal/utils.h\n> > +++ b/include/libcamera/internal/utils.h\n> > @@ -197,6 +197,8 @@ private:\n> >  \n> >  details::StringSplitter split(const std::string &str, const std::string &delim);\n> >  \n> > +std::string toAscii(const std::string &str);\n> > +\n> >  std::string libcameraBuildPath();\n> >  std::string libcameraSourcePath();\n> >  \n> > diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> > index 615df46ac142a2a9..726b84bfbae53ff2 100644\n> > --- a/src/libcamera/utils.cpp\n> > +++ b/src/libcamera/utils.cpp\n> > @@ -342,6 +342,27 @@ details::StringSplitter split(const std::string &str, const std::string &delim)\n> >  \treturn details::StringSplitter(str, delim);\n> >  }\n> >  \n> > +/**\n> > + * \\brief Strip all Unicode characters from a string\n> > + * \\param[in] str The string to strip\n> > + *\n> > + * Strip all non-ASCII characters form a string. A Unicode character that spans\n> > + * multiple bytes (and therefore is not also an ASCII character) may be\n> > + * identified by the fact that its most significant bit is always set.\n> > + *\n> > + * \\todo When switching to C++ 20 use std::remove_if.\n> > + *\n> > + * \\return An ASCII string\n> > + */\n> > +std::string toAscii(const std::string &str)\n> > +{\n> > +\tstd::string ret;\n> > +\tfor (const char &c : str)\n> > +\t\tif (!(c & 0x80))\n> > +\t\t\tret += c;\n> > +\treturn ret;\n> > +}\n> > +\n> >  /**\n> >   * \\brief Check if libcamera is installed or not\n> >   *\n> > \n> \n> -- \n> Regards\n> --\n> Kieran","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BD040BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Aug 2020 10:42:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3E9E16138F;\n\tFri, 14 Aug 2020 12:42:49 +0200 (CEST)","from mail-lj1-x242.google.com (mail-lj1-x242.google.com\n\t[IPv6:2a00:1450:4864:20::242])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AD49B60918\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Aug 2020 12:42:47 +0200 (CEST)","by mail-lj1-x242.google.com with SMTP id y2so414854ljc.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Aug 2020 03:42:47 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\ty13sm1684347ljd.19.2020.08.14.03.42.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 14 Aug 2020 03:42:46 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"BeN41J1w\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=HzLY7bi50ETktDusKG8t6kg/pRLjCLVJRPVqLnjCTcI=;\n\tb=BeN41J1w/MFBjOYdPweBNYAbTHG/uXWvujPq36nhLnj2QjxZlYZNB10IWn3ghf0IFA\n\tc4ZJQiAxdE5SQcALdJMXErY5jtKP3FukzCOKrrzNy/NB5PtJ7CvWQxZNdG9dSQSEUjbZ\n\taH+5geQm+atscSBrWhh9ac1qOAIDWI5ddwAEJ1fDMMah2T89hWvKyDKHn6D0A7ezYXUp\n\t/QOHvwbgaum9kU3NpY0DRcv8kPDZduODZ7RuF9qsbAEilE7YGpZ2qAFNS8jPRiClJCAm\n\toI8uqfTuIgvzVkvIWJY2q2pJ4KJ7Yv35zygfUjcv3H4+zl5Yfpntdz8IxTZEclnZ/6UT\n\t5vww==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=HzLY7bi50ETktDusKG8t6kg/pRLjCLVJRPVqLnjCTcI=;\n\tb=tuAoFuSvjUALRmn0in8hiNoGiSzU1ZX4IXrmo3fQSgQoTsW3/QaTL3/JMIpLrGpRBS\n\tzUcBBdxCH5PY2GFZIS68b+xyDNk1DWLAImu3Vf0g7iFrsTYRlO0d5lBk4r+nHoMkQCOS\n\tZ2zm8OJx8CDUmP6RngGTRTxRMnbFClD8X1RfAt//XPui498iY9n1CQXsHV5AQ7i2ub9Q\n\tFV+inrhn5gdQyo9uFH3/aKAVGF088M1Rg/olYC5Gi/spUe8PuY+nM+XDvXGW+xN0aSH3\n\tFv4qi8gS4kapD/1FM6AKPxnS3z1PnGaczlZ0fDliU7aFkhBIDByepeuzFEMQ+WJxkP+R\n\tpFtA==","X-Gm-Message-State":"AOAM531UYMxeLlYbK559uVG/pq9Z/DoQNvgcKiEp8I0EhjcSRREEg2yW\n\tZp5OPgXoV5DWcDbm6mUDKNNmRDCgx9Uv2A==","X-Google-Smtp-Source":"ABdhPJwl6yGRy0bgNq4UlAl324lJ7nM1OnYlWj9jtMe88FM8ptgEUtNsw+hnbRFiV4BSUZ/24qQyLQ==","X-Received":"by 2002:a2e:a0d5:: with SMTP id\n\tf21mr1132421ljm.364.1597401767051; \n\tFri, 14 Aug 2020 03:42:47 -0700 (PDT)","Date":"Fri, 14 Aug 2020 12:42:45 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20200814104245.GC1995759@oden.dyn.berto.se>","References":"<20200813223722.4050835-1-niklas.soderlund@ragnatech.se>\n\t<20200813223722.4050835-3-niklas.soderlund@ragnatech.se>\n\t<6328991c-5d43-ee18-9cff-df7b2e794203@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<6328991c-5d43-ee18-9cff-df7b2e794203@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 2/7] libcamera: utils: Add method\n\tto strip Unicode characters","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":12022,"web_url":"https://patchwork.libcamera.org/comment/12022/","msgid":"<20200816115813.GB32174@pendragon.ideasonboard.com>","date":"2020-08-16T11:58:13","subject":"Re: [libcamera-devel] [PATCH v4 2/7] libcamera: utils: Add method\n\tto strip Unicode characters","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, Aug 14, 2020 at 12:37:17AM +0200, Niklas Söderlund wrote:\n> Add method that strips non-ASCII characters from a string.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n> * Changes since v3\n> - Fix spelling in comment.\n> - Rename to toAscii()\n> ---\n>  include/libcamera/internal/utils.h |  2 ++\n>  src/libcamera/utils.cpp            | 21 +++++++++++++++++++++\n>  2 files changed, 23 insertions(+)\n> \n> diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\n> index 45cd6f120c51586b..b27f5a2323552058 100644\n> --- a/include/libcamera/internal/utils.h\n> +++ b/include/libcamera/internal/utils.h\n> @@ -197,6 +197,8 @@ private:\n>  \n>  details::StringSplitter split(const std::string &str, const std::string &delim);\n>  \n> +std::string toAscii(const std::string &str);\n> +\n>  std::string libcameraBuildPath();\n>  std::string libcameraSourcePath();\n>  \n> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> index 615df46ac142a2a9..726b84bfbae53ff2 100644\n> --- a/src/libcamera/utils.cpp\n> +++ b/src/libcamera/utils.cpp\n> @@ -342,6 +342,27 @@ details::StringSplitter split(const std::string &str, const std::string &delim)\n>  \treturn details::StringSplitter(str, delim);\n>  }\n>  \n> +/**\n> + * \\brief Strip all Unicode characters from a string\n> + * \\param[in] str The string to strip\n> + *\n> + * Strip all non-ASCII characters form a string. A Unicode character that spans\n> + * multiple bytes (and therefore is not also an ASCII character) may be\n\n\"Unicode character\" refers to the code points, while \"spans multiply\nbytes\" refers to encodings. As std::string has no notion of encoding,\nthis documentation should tell what the expected input encoding is.\n\n> + * identified by the fact that its most significant bit is always set.\n\nOpen question, do we want to remove non-ASCII characters, or replaced\nthem (with a \".\", \"?\" or something else) ?\n\n> + *\n> + * \\todo When switching to C++ 20 use std::remove_if.\n\nThat would be less efficient :-)\n\n> + *\n> + * \\return An ASCII string\n> + */\n> +std::string toAscii(const std::string &str)\n\ntoAscii() makes it sound the function converts the string, while it\nreally removes characters.\n\n> +{\n> +\tstd::string ret;\n\n\tret.reserve(str.size());\n\n> +\tfor (const char &c : str)\n> +\t\tif (!(c & 0x80))\n> +\t\t\tret += c;\n> +\treturn ret;\n> +}\n> +\n>  /**\n>   * \\brief Check if libcamera is installed or not\n>   *","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D0F51BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 16 Aug 2020 11:58:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5B4ED6170D;\n\tSun, 16 Aug 2020 13:58:31 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8924360385\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 16 Aug 2020 13:58:29 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F0EAD29F;\n\tSun, 16 Aug 2020 13:58:28 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"cCXDyGYu\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1597579109;\n\tbh=tZUe58kor58die5HBMDmgeJDqpdBnmJx7gKpbOqUm8o=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=cCXDyGYu3cO+RWxon8bRloZRCAag+BhIk6PEULe58Qt2QSaKmjthzpqNuxiDGWcH4\n\t6pb+nz4ssUWJXq8G0OYzfMB2Ws7SoFhBXcvyEMfp5+xzR/oFQPq3QnuF2QM2N8CCgt\n\tfkfYws8L2LC4cla1mbcCFDShnLCz0AFFWt+MXTBo=","Date":"Sun, 16 Aug 2020 14:58:13 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Message-ID":"<20200816115813.GB32174@pendragon.ideasonboard.com>","References":"<20200813223722.4050835-1-niklas.soderlund@ragnatech.se>\n\t<20200813223722.4050835-3-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200813223722.4050835-3-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v4 2/7] libcamera: utils: Add method\n\tto strip Unicode characters","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":12023,"web_url":"https://patchwork.libcamera.org/comment/12023/","msgid":"<20200816122950.GD2182981@oden.dyn.berto.se>","date":"2020-08-16T12:29:50","subject":"Re: [libcamera-devel] [PATCH v4 2/7] libcamera: utils: Add method\n\tto strip Unicode characters","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your feedback.\n\nOn 2020-08-16 14:58:13 +0300, Laurent Pinchart wrote:\n> On Fri, Aug 14, 2020 at 12:37:17AM +0200, Niklas Söderlund wrote:\n> > Add method that strips non-ASCII characters from a string.\n> > \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> > * Changes since v3\n> > - Fix spelling in comment.\n> > - Rename to toAscii()\n> > ---\n> >  include/libcamera/internal/utils.h |  2 ++\n> >  src/libcamera/utils.cpp            | 21 +++++++++++++++++++++\n> >  2 files changed, 23 insertions(+)\n> > \n> > diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\n> > index 45cd6f120c51586b..b27f5a2323552058 100644\n> > --- a/include/libcamera/internal/utils.h\n> > +++ b/include/libcamera/internal/utils.h\n> > @@ -197,6 +197,8 @@ private:\n> >  \n> >  details::StringSplitter split(const std::string &str, const std::string &delim);\n> >  \n> > +std::string toAscii(const std::string &str);\n> > +\n> >  std::string libcameraBuildPath();\n> >  std::string libcameraSourcePath();\n> >  \n> > diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> > index 615df46ac142a2a9..726b84bfbae53ff2 100644\n> > --- a/src/libcamera/utils.cpp\n> > +++ b/src/libcamera/utils.cpp\n> > @@ -342,6 +342,27 @@ details::StringSplitter split(const std::string &str, const std::string &delim)\n> >  \treturn details::StringSplitter(str, delim);\n> >  }\n> >  \n> > +/**\n> > + * \\brief Strip all Unicode characters from a string\n> > + * \\param[in] str The string to strip\n> > + *\n> > + * Strip all non-ASCII characters form a string. A Unicode character that spans\n> > + * multiple bytes (and therefore is not also an ASCII character) may be\n> \n> \"Unicode character\" refers to the code points, while \"spans multiply\n> bytes\" refers to encodings. As std::string has no notion of encoding,\n> this documentation should tell what the expected input encoding is.\n> \n> > + * identified by the fact that its most significant bit is always set.\n> \n> Open question, do we want to remove non-ASCII characters, or replaced\n> them (with a \".\", \"?\" or something else) ?\n\nI have not strong opinion, dropping them feels more natural to me but \nI'm open to substitution. What do other think?\n\n> \n> > + *\n> > + * \\todo When switching to C++ 20 use std::remove_if.\n> \n> That would be less efficient :-)\n> \n> > + *\n> > + * \\return An ASCII string\n> > + */\n> > +std::string toAscii(const std::string &str)\n> \n> toAscii() makes it sound the function converts the string, while it\n> really removes characters.\n\nI originally called this stripUnicode() would that name work better for \nyou?\n\n> \n> > +{\n> > +\tstd::string ret;\n> \n> \tret.reserve(str.size());\n> \n> > +\tfor (const char &c : str)\n> > +\t\tif (!(c & 0x80))\n> > +\t\t\tret += c;\n> > +\treturn ret;\n> > +}\n> > +\n> >  /**\n> >   * \\brief Check if libcamera is installed or not\n> >   *\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 81EF7BD879\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 16 Aug 2020 12:29:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0274D61815;\n\tSun, 16 Aug 2020 14:29:55 +0200 (CEST)","from mail-lj1-x243.google.com (mail-lj1-x243.google.com\n\t[IPv6:2a00:1450:4864:20::243])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F3C360918\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 16 Aug 2020 14:29:53 +0200 (CEST)","by mail-lj1-x243.google.com with SMTP id g6so14477202ljn.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 16 Aug 2020 05:29:53 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\ty1sm3958818lfb.45.2020.08.16.05.29.51\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 16 Aug 2020 05:29:51 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"L7h8CQ5J\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=/hF5LwoB6XC1RLZUsDey1vbc+q8Mo8GxLX94gA4cmfs=;\n\tb=L7h8CQ5JLVcKeg6gZUAdItlf1HBf0UWvCW7bjNqUnMI2eARzyJRMRHMFaBhwq+oyxs\n\tzYg+jtHagusfxEbVXKJAF7gNh+b1/64sSIRj4UsOJqb7mXYAd4bhZxfmNWQqztLm1ew9\n\tikxAzHr4/YuyXR1ugBHyM/LJUiqLiZmYGVp0aea/OcavAbXZmt8r4mXVzUcizzGoWw8S\n\t0oo/5QqmjjxXCNF8gQvj3aZqg7Ielsy64CG+ilDhnPuPitpNAvnzc2+VSePkpdRB6exh\n\tpB0DQIu4+sHBdMrLH21rOoOHFS+ITGL9FhyeQNfOZ+L3rb9Sh7bDXGenBhJfoCNntlxn\n\tlJVQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=/hF5LwoB6XC1RLZUsDey1vbc+q8Mo8GxLX94gA4cmfs=;\n\tb=stUwz2HxfjHukdJX6gCBZK+H+hRcAsnbdSJlb6AIP4jeHiQ/3vSw9MozcQluDdfltP\n\tUmm8YiogEfInxNPDVzI6HnwFTcuS1dbYaCUAmG0Q/C1OyZL6UUCQqlBgIdtfts/zgxAn\n\tUbfqJUFktieMR7MX/ULIdJX3Pgddfvm9fnlTXXVy9vGpUD3fDmn2wt8AuC7TJvmV844w\n\twGR8cFB3+uUY7bzorfccMgrF7L2Ubt4Kl2dWDW0oseoeieYqMxMpnrxkVm4RRlGgzqO3\n\t6gsW9VtQx0wzsP8clgHIFLmGqgbw/whQgTm6rAbEjrHskQbRahujXisGzA5FU1yQ7jnr\n\t71mA==","X-Gm-Message-State":"AOAM533AdBEpVahUM9FkgWDIR/OFdRU1NXv8IZSNBJZBV4hG2nclIrD5\n\tLKOEhg26mpFSHRrfr4yWoRXTTnfXDmXVSA==","X-Google-Smtp-Source":"ABdhPJzyBlOjbNsbDsMBdvWsDqAHQ9KQZaVbojEDYAtn2Biy8AVElxEkrr16P8neBtz+dySnSolFUA==","X-Received":"by 2002:a2e:91d2:: with SMTP id\n\tu18mr5452687ljg.436.1597580992270; \n\tSun, 16 Aug 2020 05:29:52 -0700 (PDT)","Date":"Sun, 16 Aug 2020 14:29:50 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20200816122950.GD2182981@oden.dyn.berto.se>","References":"<20200813223722.4050835-1-niklas.soderlund@ragnatech.se>\n\t<20200813223722.4050835-3-niklas.soderlund@ragnatech.se>\n\t<20200816115813.GB32174@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200816115813.GB32174@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 2/7] libcamera: utils: Add method\n\tto strip Unicode characters","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]