Skip to content

Emut/native2ascii-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

native2ascii

Convert special characters to plain ASCII text

GitHub last commit

Usage

To use with Maven, add below snippets to project's pom.xml.

Project is not on maven central, it is hosted in this repo. Because of that, it is needed to add this repo as a source in the pom.xml.

<repositories>
    <repository>
        <id>native2ascii-maven-plugin</id>
        <url>https://raw.github.com/Emut/native2ascii-maven-plugin/mvn-repo/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.github.emut</groupId>
        <artifactId>native2ascii-maven-plugin</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>com.github.emut</groupId>
            <artifactId>native2ascii-maven-plugin</artifactId>
            <version>1.0-SNAPSHOT</version>
            <configuration>
                <conversionParameters>
                    <fileParameters>
                        <fileParameter>
                            ...
                        </fileParameter>
                        <fileParameter>
                            ...
                        </fileParameter>
                    </fileParameters>
                </conversionParameters>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Examples

For the following configuration:

<fileParameters>
    <fileParameter>
        <inputFile>file.properties</inputFile>
        <outputFile>file.properties</outputFile>
        <commentPrefix>#</commentPrefix>
    </fileParameter>
</fileParameters>
Before After
Characters are converted and original line is inserted as a comment with the "[n2a]" prefix
String=with simple chars
Getting=ÇŗæƵƴ
String=with simple chars
#[n2a]Getting = ÇŗæƵƴ
Getting=\u00C7\u0157\u00E6\u01B5\u01B4
Changes to comments are reflected to converted text
String=with simple chars
#[n2a]Getting = CræƵƴ
Getting=\u00C7\u0157\u00E6\u01B5\u01B4
String=with simple chars
#[n2a]Getting = CræƵƴ
Getting=Cr\u00E6\u01B5\u01B4
If a comment exists, changes to converted lines are discarded
Changes must be made to the [n2a] comment above the line
String=with simple chars
#[n2a]Getting = CræƵƴ
Getting=Crazy
String=with simple chars
#[n2a]Getting = CræƵƴ
Getting=Cr\u00E6\u01B5\u01B4
Commented lines are simply ignored (excluding [n2a] tagged comments)
String=with simple chars
#[n2a]Getting = CræƵƴ
Getting=Crazy
#Çömment lınes are ığnöred
String=with simple chars
#[n2a]Getting = CræƵƴ
Getting=Cr\u00E6\u01B5\u01B4
#Çömment lınes are ığnöred
However inserting comments between [n2a] comments and converted lines is not a good idea,
as the line below [n2a] comment is assumed to be the related converted line
String=with simple chars
#[n2a]Getting = CræƵƴ
#Çömment lınes are ığnöred
Getting=CræƵƴ
String=with simple chars
#[n2a]Getting = CræƵƴ
Getting=Cr\u00E6\u01B5\u01B4
#[n2a]Getting = CræƵƴ
Getting=Cr\u00E6\u01B5\u01B4
Conversion comments are added to orphan lines, making future edits easier
String=with simple chars
#an orphan line
Getting=Cr\u00E6\u01B5\u01B4
String=with simple chars
#an orphan line
#[n2a]Getting = CræƵƴ
Getting=Cr\u00E6\u01B5\u01B4