2016-11-28 4 views
0

文字セットのエンコーディング形式の新しいビット。私はJavaコードをISO-8859-1形式でコンパイルするAntビルドスクリプトを持っています。それは正常に動作していた。Ant Javaビルド:コンパイルの問題 - ISO-8859-1からUTF-8への文字セットの変更

記事のカップル読んだ後:その後、コンパイルの問題が開始されてから How do I convert between ISO-8859-1 and UTF-8 in Java?

を私は、UTF-8にキャラクタ・フォーマットを変更しました。スロー

エラーは次のとおりです。

[javac] TestEncoding.java (at line 11) 
[javac] case '?' : 
[javac] ^^^^^^^^ 

マイビルド・スクリプトは、以下のい:

public class TestEncoding { 
public static final String filterAccent(String s) { 
    StringBuffer sb = new StringBuffer(); 
    int n = s.length(); 

    for (int i = 0; i < n; i++) { 
     char c = s.charAt(i); 
     switch (c) { 
     case 'á': 
      sb.append("a"); 
      break; 
     case 'à': 
      sb.append("a"); 
      break; 
     case 'ã': 
      sb.append("a"); 
      break; 
     case 'À': 
      sb.append("A"); 
      break; 
     case 'â': 
      sb.append("a"); 
      break; 
     case 'Â': 
      sb.append("A"); 
      break; 
     case 'ä': 
      sb.append("a"); 
      break; 
     case 'Ä': 
      sb.append("A"); 
      break; 
     case 'å': 
      sb.append("a"); 
      break; 
     case 'Å': 
      sb.append("A"); 
      break; 
     case 'ç': 
      sb.append("c"); 
      break; 
     case 'Ç': 
      sb.append("C"); 
      break; 
     case 'é': 
      sb.append("e"); 
      break; 
     case 'É': 
      sb.append("E"); 
      break; 
     case 'è': 
      sb.append("e"); 
      break; 
     case 'È': 
      sb.append("E"); 
      break; 
     case 'ê': 
      sb.append("e"); 
      break; 
     case 'Ê': 
      sb.append("E"); 
      break; 
     case 'ë': 
      sb.append("e"); 
      break; 
     case 'Ë': 
      sb.append("E"); 
      break; 
     case 'í': 
      sb.append("i"); 
      break; 
     case 'ì': 
      sb.append("i"); 
      break; 
     case 'ï': 
      sb.append("i"); 
      break; 
     case 'î': 
      sb.append("i"); 
      break; 
     case 'Ï': 
      sb.append("I"); 
      break; 
     default: 
      sb.append(c); 
      break; 
     } 
    } 
    return sb.toString(); 
    } 
} 

:問題を抱えている私のクラスの一つは、それのコードを、次のい

<javac compiler="org.eclipse.jdt.core.JDTCompilerAdapter" 
destdir="bin" debug="true" deprecation="on" encoding="iso-8859-1" 
source="1.6" target="1.6" 
debuglevel="lines,source" failonerror="false" errorProperty="buildFailed"> 
<compilerarg line="-warn:+raw" /> 
<compilerarg line="-warn:-serial" /> 
<compilerarg line="-log source/testapp/compileLog.xml" /> 
<src path="testapp" /> 
<classpath refid="application.classpath" /> 
</javac> 

を私はまた、文字セットをUTF-16に変更しようとしましたが、今回はdiffereをスローしましたNTエラー:

build.xml:152: com.ibm.team.repository.common.validation.PropertyConstraintException: Validation errors for item: type = CompilePackage, itemId = [UUID _ORXiULV3Eea3M7KtSY0KHw] 
    Value of attribute "compileSources.errors.sourceText" is 67854 bytes, which is greater than the allowed encoded length of 32768 bytes. 
    Value of attribute "compileSources.errors.sourceText" is 58296 bytes, which is greater than the allowed encoded length of 32768 bytes. 
    Value of attribute "compileSources.errors.sourceText" is 36105 bytes, which is greater than the allowed encoded length of 32768 bytes. 
    Value of attribute "compileSources.errors.sourceText" is 127899 bytes, which is greater than the allowed encoded length of 32768 bytes. 
    Value of attribute "compileSources.errors.sourceText" is 155844 bytes, which is greater than the allowed encoded length of 32768 bytes. 
    Value of attribute "compileSources.errors.sourceText" is 120795 bytes, which is greater than the allowed encoded length of 32768 bytes. 
    Value of attribute "compileSources.errors.sourceText" is 81561 bytes, which is greater than the allowed encoded length of 32768 bytes. 
    Value of attribute "compileSources.errors.sourceText" is 33264 bytes, which is greater than the allowed encoded length of 32768 bytes. 
    Value of attribute "compileSources.errors.sourceText" is 35163 bytes, which is greater than the allowed encoded length of 32768 bytes. 
    Value of attribute "compileSources.errors.sourceText" is 96396 bytes, which is greater than the allowed encoded length of 32768 bytes. 
    at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.failIfNecessary(RdbRepositoryDataMediator.java:456) 
    at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.validateItem(RdbRepositoryDataMediator.java:405) 

誰かがこれを助けることができますか?

おかげで、よろしく、

ビジェイ・レディ。

+0

'javac'タスクの' encoding'属性がソースファイルの実際のエンコーディングと一致することを確認してください。 – Berger

+0

私のソースファイルの文字エンコーディングはcp-1252です。しかし、ISO-8859-1を使用すると、UTF-8がそうでない場所でうまく動作します。 –

+1

CP-1252とISO-8859-1は非常に近いエンコーディングです。ほとんどの文字は同じ方法で表現されます。ソースファイルをUTF-8でエンコードし、UTF-8を 'encoding'属性として指定してください。 – Berger

答えて

0

エンコードレベルで複数のことを試しました。何も働かなかった。

最後に私はBergerの提案を試して、ソースコードをUTF-8にエンコードする形式を変更し、UTF-8を使ってビルドしても問題ありません。注目を維持しなければならないのは、プロジェクトで使用されている特殊文字だけです。プロジェクトレベルのエンコーディングが変更されるとすぐに、特殊文字が??に変更されました。シンボル。私はこれらすべてを変換する必要がありますか?実際の特殊文字に変換します。これが私が費やす唯一の努力でした。これは開発者にとっては面倒な状況になる可能性がありますが、これは開発者/プロジェクトごとの1回のアクティビティなので、これは問題ありません。

提案に感謝します。

関連する問題