Archived

This forum has been archived. Please start a new discussion on GitHub.

Unknown encoding Problem?

Hi, all,

I trying to compile Hello.ice to java, and get the following error message:
E:\Ice-3.3.0\demoj\IceGrid\ice_grid>slice2java Hello.ice
E:/Ice-3.3.0/demoj/IceGrid/ice_grid/Hello.ice:0: warning: Unknown encoding: zh_CN


It seems that Ice-3.3.0 does not support Chinese language, for when I switch to Ice-3.2.1 and it works.
// **********************************************************************
//
// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#ifndef HELLO_ICE
#define HELLO_ICE

module Demo
{

interface Hello
{
    idempotent void sayHello();
    void shutdown();
};

};

#endif

Comments

  • bernard
    bernard Jupiter, FL
    Thanks for the bug report. We've actually seen this warning before but it does not appear to be locale-dependent or to affect the generated code.

    Do you get this warning each time you run slice2java on Hello.ice? Is there any problem with the generated Java code?

    Thanks,
    Bernard
  • I use GVIM as slice language editor, somtimes I see this warning message, then I try to use Eclipse text editor, retype it, recompile it, and sometimes it is OK.

    Now, this morning, I try to ANT task to build the slice source, and it is OK.

    Here is my ant code:
    <project basedir="." default="all">
    	<property name="ice.home" value="E:\Ice-3.3.0" />
    	<property name="ant.task.dir" value="${ice.home}/ant" />
    	<target name="all">
    		<mkdir dir="dist" />
    		<delete dir="src">
    			<include name="message/service/*.java" />
    			<include name="message/entity/*.java" />
    			<include name="okooo/util/*.java" />
    			<include name="*depend" />
    		</delete>
    		<taskdef name="slice2java" classpath="${ant.task.dir}" classname="Slice2JavaTask" />
    		<slice2java outputdir="src" includepath=".">
    			<fileset dir="." includes="message.service.ice" />
    			<fileset dir="." includes="okooo.util.ice" />
    			<fileset dir="." includes="message.entity.ice" />
    		</slice2java>
    	</target>
    </project>
    

    So what is difference between ANT task and slice2java?
  • Hi, bernard,
    There is no problem with the generated java code, but I need more features. for example, here is the source slice code:
    ["java:getset"]
    struct City{
    string id;
    string name;
    string provinceId;
    };

    and the generated java code is:
    package message.entity;

    public final class City implements java.lang.Cloneable {
    public String id;

    public String getId() {
    return id;
    }

    public void setId(String _id) {
    id = _id;
    }

    public String name;

    public String getName() {
    return name;
    }

    public void setName(String _name) {
    name = _name;
    }

    public String provinceId;

    public String getProvinceId() {
    return provinceId;
    }

    public void setProvinceId(String _provinceId) {
    provinceId = _provinceId;
    }

    public City() {
    }

    public City(String id, String name, String provinceId) {
    this.id = id;
    this.name = name;
    this.provinceId = provinceId;
    }

    public boolean equals(java.lang.Object rhs) {
    if (this == rhs) {
    return true;
    }
    City _r = null;
    try {
    _r = (City) rhs;
    } catch (ClassCastException ex) {
    }

    if (_r != null) {
    if (id != _r.id && id != null && !id.equals(_r.id)) {
    return false;
    }
    if (name != _r.name && name != null && !name.equals(_r.name)) {
    return false;
    }
    if (provinceId != _r.provinceId && provinceId != null
    && !provinceId.equals(_r.provinceId)) {
    return false;
    }

    return true;
    }

    return false;
    }

    public int hashCode() {
    int __h = 0;
    if (id != null) {
    __h = 5 * __h + id.hashCode();
    }
    if (name != null) {
    __h = 5 * __h + name.hashCode();
    }
    if (provinceId != null) {
    __h = 5 * __h + provinceId.hashCode();
    }
    return __h;
    }

    public java.lang.Object clone() {
    java.lang.Object o = null;
    try {
    o = super.clone();
    } catch (CloneNotSupportedException ex) {
    assert false; // impossible
    }
    return o;
    }

    public void __write(IceInternal.BasicStream __os) {
    __os.writeString(id);
    __os.writeString(name);
    __os.writeString(provinceId);
    }

    public void __read(IceInternal.BasicStream __is) {
    id = __is.readString();
    name = __is.readString();
    provinceId = __is.readString();
    }
    }

    I want this generated City class to implement java.io.Serializable interface, but I don't know how config the metadata to generate it. I download the Ice source code, and I want to recompile the slice2java, but I don't how to compile cpp code, for I am a java programmer.

    And now I am also interested in the formal language and the compile technology too. Recently, I use ANTLR to develope some DSL for our special need of our company.

    ANTLR can use the source template to generate the target source code, maybe it's easy for ANTLR to modify the source template to affect the generated source code. But Ice use YACC to compile, all the code generator logic is embeded within cpp source code, so it's difficult to modify the behavior of generator.