wxT Macro fails

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
goeba
Earned a small fee
Earned a small fee
Posts: 21
Joined: Tue May 17, 2005 8:13 pm

wxT Macro fails

Post by goeba » Sat Nov 19, 2016 8:32 am

Hi,

I´m using wxT on the following string:

wxT("\\lstset{ inputencoding=utf8, literate={ä}{{\\\"a}}1 {ö}{{\\\"o}}1 {ü}{{\\\"u}}1 {Ä}{{\\\"A}}1 {Ö}{{\\\"O}}1 {Ü}{{\\\"U}}1 {ß}{{\\\"s}}1 {´}{{'}}1,}\n") <<

It´s for creating a LaTeX-File, that is why there are so many backslashes.

The macro fails with

Code: Select all

home/linux/Downloads/wxWidgets-3.1.0/include/wx/chartype.h:210:44: error: converting to execution character set: Ungültiges oder unvollständiges Multi-Byte- oder Wide-Zeichen
***              #define wxT(x) wxCONCAT_HELPER(L, x)
***                                             ^
*** /home/linux/Downloads/wxWidgets-3.1.0/include/wx/cpp.h:18:37: note: in definition of macro ‘wxCONCAT_HELPER’
***  #define wxCONCAT_HELPER(text, line) text ## line
***                                      ^
*** kartei.cpp:326:5: note: in expansion of macro ‘wxT’
***      wxT("\\lstset{ inputencoding=utf8, literate={
*** }}1 {
*** }}1 {
*** }}1 {
*** }}1 {
*** }}1 {
*** }}1 {
*** }}1 {
*** }\n") <<
***      ^
Makefile:239: recipe for target 'GCCReleaseGTK/kartei.o' failed
*** make: *** [GCCReleaseGTK/kartei.o] Error 1
Do you think it´s a bug, should I submit it? The only multibyte-Characters here are umlauts.

User avatar
doublemax
Moderator
Moderator
Posts: 14897
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxT Macro fails

Post by doublemax » Sat Nov 19, 2016 9:32 am

In Unicode mode the wxT macro just expands to "L". I'm pretty sure that's not the problem here.

Please show the complete code line.
Use the source, Luke!

goeba
Earned a small fee
Earned a small fee
Posts: 21
Joined: Tue May 17, 2005 8:13 pm

Re: wxT Macro fails

Post by goeba » Sat Nov 19, 2016 11:32 am

Code: Select all

speichern <<
    
    "\\documentclass[10pt, pdftex]{article}\n"<<
    "\\usepackage{ngerman}\n"<<

    "\\usepackage[utf8]{inputenc}\n"<<
    "\\usepackage[T1]{fontenc}\n"<<
    "\\usepackage{times}\n"<<

    "\\usepackage[top=1cm, bottom=1cm, left=1cm, right=1.5cm, nohead, nofoot]{geometry}\n"<<
    "\\usepackage{enumerate}\n"<<
    "\\usepackage{epsfig}\n"<<
    "\\usepackage{graphics}\n"<<
    "\\usepackage{multicol}\n"<<
    "\\usepackage{calc}\n"<<
    "\\usepackage{boxedminipage}\n"<<
    "\\usepackage{amsmath}\n"<<
    "\\usepackage{amssymb}\n"<<
    "\\usepackage{multicol}\n"<<
    "\\usepackage{morefloats}\n"<<
    "\\usepackage{listings}\n"<<
    "\\newcounter{anzkarten}\n"<<

    "\\newenvironment{karte}\n"<<
	    "{\\begin{figure}[tbp]%\n"<<
	    "\\stepcounter{anzkarten}\n"<<


		"\\begin{boxedminipage}{\\textwidth}%\n"<< counterprefix <<
		": Karte \\theanzkarten\n"<<
		"\\setlength{\\columnseprule}{2pt}%\n"<<
		"\\raggedcolumns%\n"<<
		"\\begin{multicols}{2}%\n"<<
	"}\n"<<
	"{	\\end{multicols}%\n"<<
	"\\end{boxedminipage}%\n"<<
	"\\end{figure}%\n"<<
	"}\n"<<
	"\\newcommand{\\antwort}{\\columnbreak}\n"<<
	"\\renewcommand{\\textfraction}{0}\n"<<
	"\\renewcommand{\\topfraction}{1}\n"<<
	"\\renewcommand{\\bottomfraction}{1}\n"<<
	"\\setlength{\\floatsep}{0pt}\n"<<
	"\\setlength{\\textfloatsep}{0pt}\n"<<
	"\\setlength{\\intextsep}{0pt}\n"<<
	"\\setcounter{totalnumber}{10}\n"<<
	"\\setcounter{topnumber}{10}\n"<<
	"\\setcounter{bottomnumber}{10}\n"<<
    
    "\\newcommand{\\vecII}[2]{\n"<<
    "\\ensuremath{\n"<<
    "\\begin{pmatrix}\n"<<
    "#1	\\\\\n"<<
    "#2	\\\\\n"<<
    "\\end{pmatrix}\n"<<
    "}\n"<<
    "}\n"<<
    "\\newcommand{\\vecIII}[3]{\n"<<
    "\\ensuremath{\n"<<
    "\\begin{pmatrix}\n"<<
    "#1	\\\\\n"<<
    "#2	\\\\\n"<<
    "#3 \\\\\n"<<
    "\\end{pmatrix}\n"<<
    "}\n"<<
    "}\n"<<
    "\\newcommand{\\V}[1]{\\overrightarrow{#1}}\n"<<
    wxT("\\lstset{ inputencoding=utf8, literate={ä}{{\\\"a}}1 {ö}{{\\\"o}}1 {ü}{{\\\"u}}1 {Ä}{{\\\"A}}1 {Ö}{{\\\"O}}1 {Ü}{{\\\"U}}1 {ß}{{\\\"s}}1 {´}{{'}}1,}\n") <<


	"\\begin{document}\n"<<
	"\\pagestyle{empty}\n";
Sorry, it´s a rather long line.

User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 429
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: wxT Macro fails

Post by xaviou » Sat Nov 19, 2016 12:35 pm

Hi.

One thing to check : as you are using Unicode, is your source file correctly encoded ?

Error like this generally append when using unicode strings in an ascii source file.

Regards
Xav'
My wxWidgets stuff web page : [email protected]'s wxStuff

goeba
Earned a small fee
Earned a small fee
Posts: 21
Joined: Tue May 17, 2005 8:13 pm

Re: wxT Macro fails

Post by goeba » Sat Nov 19, 2016 4:06 pm

Hi,

thanks for the tip. I checked, the source file is encoded iso-8859-1 , which is also my setting for the source encoding (I build with dialog blocks).

That´s what uchardet says:
uchardet kartei.cpp
ISO-8859-1

So I still think that it´s a bug in wxWidgets - or perhaps in dialog blocks.

Andreas

User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 429
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: wxT Macro fails

Post by xaviou » Sat Nov 19, 2016 4:11 pm

goeba wrote:So I still think that it´s a bug in wxWidgets - or perhaps in dialog blocks.
I don't think so...

If you use unicode strings, you should use unicode encoded sources files.
Try to convert the source file : it should compile.

Regards
Xav'
My wxWidgets stuff web page : [email protected]'s wxStuff

User avatar
doublemax
Moderator
Moderator
Posts: 14897
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxT Macro fails

Post by doublemax » Sat Nov 19, 2016 4:19 pm

Compiles for me with VS2013 under Windows.

But because of the many slashes need to escape slashes and quotes, i personally would put that in an external file with some placeholders for the variable parts. That would make maintaining this much easier.
Use the source, Luke!

goeba
Earned a small fee
Earned a small fee
Posts: 21
Joined: Tue May 17, 2005 8:13 pm

Re: wxT Macro fails

Post by goeba » Sat Nov 19, 2016 4:45 pm

@xaviou: I thought that using wxT( ...) should make it possible to build unicode apps using a different source encoding. Dialog Blocks doesn´t offer the possibility to change the source-encoding after project-start, so I´m afraid that I´d mess up the project when doing this myself.

@doublemax: I thought so, too, to avoid that problem on one hand, to make this more flexible on the other.

I think I´ll write Julian a message to ask what Dialog BLocks does with the iso-8859-1 encoded source-file.

I really hate all this encoding-stuff. I really wish that someone 50 years ago would have invented unicode right from the start ...

This is an old program which I am currently porting to linux (from windows, using wx ansi 2.8). I have to deal with the fact that the files produced by the application are windows-encoded, that the LaTeX-Export must take care of the right encoding and all this ... But you all know that when you´re 95% done, 95% of the work begin ;)

Post Reply