Problems with copy code from forum
-
When I copy the code of a code snippet in the forum (eg the second comment in "this thread":http://developer.qt.nokia.com/forums/viewthread/1960/#8968) and paste it into an editor (vi, MacVim, Qt Creator) and compile the stuff, I get the following error messages:
@
g++-4.0 -c -pipe -O2 -arch i386 -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.7.0/mkspecs/macx-g++40 -I. -I/usr/local/Trolltech/Qt-4.7.0/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Trolltech/Qt-4.7.0/include/QtCore -I/usr/local/Trolltech/Qt-4.7.0/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Trolltech/Qt-4.7.0/include/QtGui -I/usr/local/Trolltech/Qt-4.7.0/include -I. -I. -F/usr/local/Trolltech/Qt-4.7.0/lib -o main.o main.cpp
main.cpp:3: error: stray ‘\194’ in program
main.cpp:3: error: stray ‘\160’ in program
main.cpp:6: error: stray ‘\194’ in program
main.cpp:6: error: stray ‘\160’ in program
main.cpp:6: error: stray ‘\194’ in program
main.cpp:6: error: stray ‘\160’ in program
main.cpp:6: error: stray ‘\194’ in program
main.cpp:6: error: stray ‘\160’ in program
main.cpp:6: error: stray ‘\194’ in program
main.cpp:6: error: stray ‘\160’ in program
main.cpp:7: error: stray ‘\194’ in program
main.cpp:7: error: stray ‘\160’ in program
@It seems that there is a problem with some special html chars.
I'm on a Mac using Safari 5.
-
Hi Volker,
I tried and not able to reproduce it in linux (Kubuntu) with firefox
Linux dosen't says if there are some special chars added.
@$ od --format=c x.cpp
0000000 # i n c l u d e < Q A p p l i c
0000020 a t i o n > \n # i n c l u d e <
0000040 Q S p l i t t e r > \n \n i n t
0000060 m a i n ( i n t a r g c ,
0000100 c h a r * a r g v [ ] ) \n {
0000120 \n Q A p p l i c a t i o
0000140 n a p p ( a r g c , a r g
0000160 v ) ; \n \n Q S p l i
0000200 t t e r * s p l i t t e r =
0000220 n e w Q S p l i t t e r ; \n
0000240 s p l i t t e r - > s e
0000260 t F i x e d S i z e ( 3 0 0 ,
0000300 3 0 0 ) ; \n Q W i d
0000320 g e t * w i d g e t 1 = n
0000340 e w Q W i d g e t ( s p l i
0000360 t t e r ) ; \n Q W i d
0000400 g e t * w i d g e t 2 = n
0000420 e w Q W i d g e t ( s p l i
0000440 t t e r ) ; \n w i d g
0000460 e t 1 - > s e t S t y l e S h e
0000500 e t ( " Q W i d g e t { b a
0000520 c k g r o u n d : r e d } "
0000540 ) ; \n w i d g e t 2 - >
0000560 s e t S t y l e S h e e t ( "
0000600 Q W i d g e t { b a c k g r o
0000620 u n d : b l u e } " ) ; \n
0000640 \n w i d g e t 1 - > s e
0000660 t C o n t e n t s M a r g i n s
0000700 ( 0 , 0 , 0 , 0 ) ; \n
0000720 w i d g e t 2 - > s e t C o n
0000740 t e n t s M a r g i n s ( 0 ,
0000760 0 , 0 , 0 ) ; \n \n s
0001000 p l i t t e r - > a d d W i d g
0001020 e t ( w i d g e t 1 ) ; \n
0001040 s p l i t t e r - > a d d
0001060 W i d g e t ( w i d g e t 2
0001100 ) ; \n \n / / I w a n
0001120 t t h a t t h e s p a c e
0001140 b e t w e e n w i d g e t s
0001160 t o b e o n l y a l i
0001200 n e \n Q S p l i t t e r
0001220 H a n d l e * h a n d l e =
0001240 s p l i t t e r - > h a n d l
0001260 e ( 1 ) ; \n h a n d l e
0001300 - > s e t F i x e d W i d t h (
0001320 1 ) ; \n \n s p l i
0001340 t t e r - > s h o w ( ) ; \n \n
0001360 r e t u r n a p p . e
0001400 x e c ( ) ; \n } \n
0001411
@I will again try it on mac.
If you have some more information to reproduce it then please let us know.
-
Here's what we got on my Mac.
@$ od -t c x.cpp
0000000 l u d e < Q A p p l i c a t i o
0000020 n > \n # i n c l u d e < Q S p l
0000040 i t t e r > \n \n i n t m a i
0000060 n ( i n t a r g c , c h a
0000100 r * a r g v [ ] ) \n { \n
0000120 Q A p p l i c a t i o n a p
0000140 p ( a r g c , a r g v ) ;
0000160 \n \n Q S p l i t t e r
0000200 * s p l i t t e r = n e w
0000220 Q S p l i t t e r ; \n
0000240 s p l i t t e r - > s e t F i x
0000260 e d S i z e ( 3 0 0 , 3 0 0
0000300 ) ; \n Q W i d g e t *
0000320 w i d g e t 1 = n e w Q
0000340 W i d g e t ( s p l i t t e r
0000360 ) ; \n Q W i d g e t *
0000400 w i d g e t 2 = n e w Q
0000420 W i d g e t ( s p l i t t e r
0000440 ) ; \n w i d g e t 1 -
0000460 > s e t S t y l e S h e e t (
0000500 " Q W i d g e t { b a c k g r
0000520 o u n d : r e d } " ) ; \n
0000540 w i d g e t 2 - > s e t S
0000560 t y l e S h e e t ( " Q W i d
0000600 g e t { b a c k g r o u n d :
0000620 b l u e } " ) ; \n \n
0000640 w i d g e t 1 - > s e t C o n
0000660 t e n t s M a r g i n s ( 0 ,
0000700 0 , 0 , 0 ) ; \n w i d
0000720 g e t 2 - > s e t C o n t e n t
0000740 s M a r g i n s ( 0 , 0 , 0 ,
0000760 0 ) ; \n \n s p l i t
0001000 t e r - > a d d W i d g e t (
0001020 w i d g e t 1 ) ; \n s
0001040 p l i t t e r - > a d d W i d g
0001060 e t ( w i d g e t 2 ) ; \n
0001100 \n / / I w a n t t h
0001120 a t t h e s p a c e b e t
0001140 w e e n w i d g e t s t o
0001160 b e o n l y a l i n e \n
0001200 Q S p l i t t e r H a n d
0001220 l e * h a n d l e = s p l
0001240 i t t e r - > h a n d l e ( 1 )
0001260 ; \n h a n d l e - > s e
0001300 t F i x e d W i d t h ( 1 )
0001320 ; \n \n s p l i t t e r
0001340 - > s h o w ( ) ; \n \n
0001360 r e t u r n a p p . e x e c (
0001400 ) ; \n } \n
0001405
@ -
On a mac I get this, when I paste the copied text to hexdump:
@
volker@macpro ~ $ hexdump -C
QApplication app( argc, argv );
00000000 c2 a0 c2 a0 c2 a0 c2 a0 51 41 70 70 6c 69 63 61 |........QApplica|
@instead of 20 for the spaces there is c2 a0 in the copied text, which are the UTF-8 bytes for non-breaking space (   ).
The HTML source code does only contain regular spaces, I think something is going on with the syntax highlighter or it is a Mac/Safari specific bug, since on Arora I do not get this strange conversion.