C++ Logo

SG16

Advanced search

Subject: Re: [SG16-Unicode] [isocpp-core] Source file encoding
From: Thiago Macieira (thiago_at_[hidden])
Date: 2019-08-14 14:50:35


On Wednesday, 14 August 2019 09:00:43 PDT Steve Downey wrote:
> > #pragma encoding <encoding> switches encoding from the #pragma onwards.
> >
> For the rest of that source file. A push/pop mechanism so you can't cause
> errors in the file doing the inclusion.

You make it for the file in question, not the translation unit. That means it
won't affect #includes and terminates at the end of your #inclusion.

This also means preprocessors need to understand that for the # lines.

# 1 "foo.cpp"
#pragma encoding "utf-8"
"this is UTF-8"
# 1 "foo.h"
#pragma encoding "latin1"
"this is Latin1"
# 3 "foo.cpp"
"this is again automatically UTF-8"

Which could get funny with lex outputs... then again, I don't think lex can
handle multibyte.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

SG16 list run by sg16-owner@lists.isocpp.org