nagyistoce / qdevelop

Automatically exported from code.google.com/p/qdevelop
GNU General Public License v2.0
0 stars 0 forks source link

AStyle-Plugin breaks source file non-latin encoding #354

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open file with comments in non-latin encoding (eg.: russian in utf-8)
2. Use astyle-plugin

What is the expected output? What do you see instead?
Comments encoding becomes broken.

It's because astyle-plugin ignores "codec" parameter in text() function/

Original issue reported on code.google.com by Lord.Div...@gmail.com on 26 Feb 2009 at 12:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I use UTF-8 for my projects source. And use unicode, russians symbols.
I like QDevelop  and that is why I start modify source of astyle plugin. And I 
solve 
the problem.

Solving:

In file astyleplugin.cpp in astyle-plugin-rev3.zip
using method of QString - toLocal8Bit()
This metod damage all not ASCII symbols (0 - 127).

I try to solve this by some modify:

#include <QTextStream>

...

QString AStylePlugin::text(QString text, QString selectedText)
{

...     
    // Open temp file for writing

    QFile file( f );
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text ) )
        return QString();

    QTextStream out(&file);

    //out.setCodec("UTF-8");

        out << text;    

    //!!! Old version:  file.write( text.toLocal8Bit() ); - damage all not ASCII 
symbols (0 - 127)
    file.close();

    ... 

    //Read results

    file.open( QIODevice::ReadOnly | QIODevice::Text );

        QTextStream in(&file);

        //in.setCodec("UTF-8");

        QString formattedContent;

    formattedContent  = in.readAll();

    /*!!! Old version: Same problems    

    QString formattedContent = file.readAll();

    */

    file.close();

    ...     

}

By using QTextStream now I can work whith unicode and dont afread damage 
comments!

Original comment by logforal...@googlemail.com on 4 Mar 2009 at 3:10

Attachments:

GoogleCodeExporter commented 9 years ago
Would you mind creating a patch against the newest version of astyle-plugin?
It's located:
http://qdevelop.googlecode.com/files/qdevelop-astyle-plugin-0.27.0-src.tar.bz2
It has additional "codec" parameter which was ignored in rev3.
Thank you

Original comment by Lord.Div...@gmail.com on 4 Mar 2009 at 7:25

GoogleCodeExporter commented 9 years ago
Fixed in r435

Original comment by Lord.Div...@gmail.com on 5 Mar 2009 at 11:38