This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How could I change the default charset in package.bld.xml

Hi

I want to auto change the default charset in package.bld.xml  at  line 1 automantic when compile the souce code. the default charset is UTF-8.

<?xml version="1.0" encoding="UTF-8"?>

This make the compile process break .  because my source code path name have multibytes words.
If I manual change the encode type to my local charset. the compile could be success.

The full error message as follow:

[Fatal Error] package.bld.xml:10:49: Invalid byte 2 of 2-byte UTF-8 sequence.
org.xml.sax.SAXParseException: Invalid byte 2 of 2-byte UTF-8 sequence.
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:146)
        at xdc.services.intern.gen.JClass.genPkgBuild(JClass.java:852)
        at xdc.services.intern.gen.JClass.genPkgValues(JClass.java:1009)
        at xdc.services.intern.gen.JClass.gen(JClass.java:194)
        at xdc.services.intern.cmd.Builder.gen(Builder.java:235)
        at xdc.services.intern.cmd.Builder.main(Builder.java:139)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
        at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
        at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3237)
        at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2394)
        at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:176)
        at org.mozilla.javascript.Context.evaluateReader(Context.java:1227)
        at config.Shell.evaluateLoad(Shell.java:789)
        at config.Shell.processLoad(Shell.java:672)
        at config.Shell.load(Shell.java:1229)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
        at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:411)
        at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3237)
        at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2394)
        at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:173)
        at org.mozilla.javascript.Context.evaluateReader(Context.java:1227)
        at config.Shell.evaluateReader(Shell.java:830)
        at config.Shell.processReader(Shell.java:499)
        at config.Shell.processFile(Shell.java:561)
        at config.Shell.exec(Shell.java:773)
        at config.Shell.main(Shell.java:1376)
gmake: *** [package/package.xdc.inc] Error 1

 

 

 

 

 

 

 

  • Steven,

    Can you post the package.bld.xml file that is causes the problem?  Also what did you change the "encoding=..." string to in order to make the build succeed?

    If we can detect your character set at the time this file is generated, we can avoid this failure.

     

    dave

     

     

     

  • hello dave:

    pls kindly check the attachment.

    and my locale is

    # locale
    LANG=zh_CN
    LC_CTYPE="zh_CN"
    LC_NUMERIC="zh_CN"
    LC_TIME="zh_CN"
    LC_COLLATE="zh_CN"
    LC_MONETARY="zh_CN"
    LC_MESSAGES="zh_CN"
    LC_PAPER="zh_CN"
    LC_NAME="zh_CN"
    LC_ADDRESS="zh_CN"
    LC_TELEPHONE="zh_CN"
    LC_MEASUREMENT="zh_CN"
    LC_IDENTIFICATION="zh_CN"
    LC_ALL=

  • Steven said:

    hello dave:

    pls kindly check the attachment.

    and my locale is

    # locale
    LANG=zh_CN
    LC_CTYPE="zh_CN"
    LC_NUMERIC="zh_CN"
    LC_TIME="zh_CN"
    LC_COLLATE="zh_CN"
    LC_MONETARY="zh_CN"
    LC_MESSAGES="zh_CN"
    LC_PAPER="zh_CN"
    LC_NAME="zh_CN"
    LC_ADDRESS="zh_CN"
    LC_TELEPHONE="zh_CN"
    LC_MEASUREMENT="zh_CN"
    LC_IDENTIFICATION="zh_CN"
    LC_ALL=

    Steven,

    Thanks!  I've filed a bug against RTSC to track this issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=314735.

    I wonder if the build works if we simply declare the encoding as UTF-16 instread of UTF-8?  If so, it should be quite easy for us to fix.

    Thanks for your patience,

    dave

    PS: Since RTSC is an open source project, you can follow and file additional bugs at eclipse.org.  If you register with eclipse.org, I can add you to the "CC list" for this bug and you will automatically get an email when the state of the bug changes (e.g., when it get's fixed).

     

  • Hi dave

    Thanks for your quickly reply.

    The build process still break when change the encodeing from UTF-8 to UTF-16.
    I think that is because my locale is based on multibytes.

    BTW:  I could not  change the locale to UTF-8 because of the rule of our project.

    I'm not familiar with RTSC. So I want to know, Is there any way to change the content of package.bld.xml right after generated it?
    If  there is ,  I can the the encoding automantic  in my Makefile to avoid the build process break.

    Waiting for your early reply

    Best Regards

  • Steven said:

    Hi dave

    Thanks for your quickly reply.

    The build process still break when change the encodeing from UTF-8 to UTF-16.
    I think that is because my locale is based on multibytes.

    BTW:  I could not  change the locale to UTF-8 because of the rule of our project.

    I'm not familiar with RTSC. So I want to know, Is there any way to change the content of package.bld.xml right after generated it?
    If  there is ,  I can the the encoding automantic  in my Makefile to avoid the build process break.

     

    Steven,

    If you are using package.bld to build a package, it's relatively simply to "patch" the generated/package.bld.xml file.  One way is to add the following line to the package.bld script:

        Pkg.makeEpilogue = "include custom.mak";

    Then create a makefile named custom.mak with the following lines:

    all: .fix_xml

    .fix_xml: package/package.bld.xml
            @echo patching $< ...
            @$(SED) -i -e 's/encoding="UTF-8"/encoding="gb2312"/' $<

    Make sure the whitespace in front of the @ characters above are tabs (not spaces), otherwise make will not recognize the commands. 

    The line in the package.bld script simply adds a line to the generated makefile which simply includes the makefile, named custom.mak, that you create by hand. (see http://rtsc.eclipse.org/cdoc-tip/index.html#xdc/bld/PackageContents.html#make.Epilogue)

    I hope this helps,

    dave

     

  •  Dear Dave

    Many thanks for your support.

    I have avoided the problem by add some fault-tolerance  code in my Makefile.

    Here is my solution for it :
    in Makefile , do the following  change could avoid the problem, however for a clean make or a incrementation  make.

    DVSDKCOMPILE = $(VERBOSE) XDCPATH="$(XDC_PATH)" $(CONFIGURO) -c $(MVTOOL_DIR) -o $(XDC_CFG) -t $(XDC_TARGET) -p $(XDC_PLATFORM)
        $(XDC_CFGFILE)
    ($(DVSDKCOMPILE) || (sed -i -e 's/encoding="UTF-8"/encoding="gb2312"/' $(XDC_CFG)/package/package.bld.xml )) && $(DVSDKCOMPI
        LE)

    Best Regards

  • resolve out of the DVSDK