XML ports codepage problem

lzrlzr Member Posts: 264
We have a customer who has russian and swedish data in the same database (two different companies). Now the customer wants to integrate NAV 4.0 with a second system. Both companies should be integrated with the new system using XML.

Data should be sent on a regular basis using one application server. The problem is that data is stored in two different codepages. From what I have read NAV does not support unicode and it does not matter that I can export using UTF-8, the result will be different if the NAS uses Swedish/Russian codepage.

Does anyone have any tip on how to make this integration? I can think of two alternatives only:

1. Two application server, one for russia and one for sweden. All files are separated.
2. Make some kind .NET extension which transforms the russian characters.

Are there any other solutions to this problem?
Navision developer

Answers

  • jlandeenjlandeen Member Posts: 524
    Is the data in 2 seperate companies?

    If it is you will probably require 2 NAS instances as each instance is tied to a company.

    Is the data in the 2 companies completely seperate or are you using any of the inter-company features of 4.0 to roll up the data to a master company. If so you could just use the master company to export all data.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • ara3nara3n Member Posts: 9,256
    edited 2008-03-18
    lzr. The companies have different codepages?

    Are you using citrix or rdp? and do you have separate rdp for each company?

    What is the codepage on the sql server?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • EugeneEugene Member Posts: 309
    if i understand right one company is used by sweden subsidiary and another company is used by russian subsidiary each working separately.

    but it is interesting to know what is the codepage on the sql server?
    as far as i know russians use extended ASCII - for russian characters they use codes over 127 (with 8th bit set to 1). If this is a case i believe both sweden and russian characters can sit in one codepage
  • lzrlzr Member Posts: 264
    Thanks for your answers.

    The environment looks like this:

    1. Swedish database server (native) with two different companies, one swedish company and one russian company in the same (swedish) database.

    2. Swedish remote desktop server - swedish users connect from here
    3. Russian remote desktop server - russian users connect from here
    Navision developer
  • lzrlzr Member Posts: 264
    I have now solved this problem by creating an extension in C#, compiling it as an automation and calling it from NAV to parse through the generated xml data and convert it to unicode.
    Navision developer
  • ara3nara3n Member Posts: 9,256
    would you mind sharing the code and post it in here?
    I'm sure other people would find it very useful.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • lzrlzr Member Posts: 264
    OK, here goes:

    XML file (english codepage):
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <customer>
    	<customerid>1</customerid>
    	<country>RU</country>
    	<name>ÄÆÉÄ"</name>
    	<address>ÅÉÉÉÑ«Ñß, 123</address>
    	<city>æ¡ÅÑÔÉÉÑÓú</city>
    	<postcode>12121</postcode>
    </customer>
    

    C# Extension:
    using System.Runtime.InteropServices;
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    using System.Xml;
    
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface IConvertXML
    {
        /*
         * Set input file
        */
        [DispId(1)]
        void Open(String path);
    
        /*
        * Convert xml from NAV
        */
        [DispId(2)] 
        void Save(String OutputFile);
    
        /*
         * Set Starting node
        */
        [DispId(3)]
        void StartAtNode(String NodePath);
    }
    
    [ClassInterface(ClassInterfaceType.AutoDual)]
    public class ConvertXML : IConvertXML
    {
        private String InputFile;
        private String NodePath;
        
        public void Open(String path)
        {
            InputFile = path;
        }
        public void StartAtNode(String NodePath)
        {
            this.NodePath = NodePath;
        }   
        public void Save(String OutputFile)
        {          
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(InputFile);
            XmlNodeList xmlNodeList = xmlDoc.SelectNodes(NodePath);
    
            foreach (XmlNode xmlNode in xmlNodeList)
            {
                bool russian = false;           
    
                if (xmlNode.ChildNodes.Item(1).Name == "country")
                {
                    russian = xmlNode.ChildNodes.Item(1).InnerText == "RU";                
                }
    
                for (int i = 2; i < xmlNode.ChildNodes.Count; i++)
                {
                    if (russian)
                        xmlNode.ChildNodes.Item(i).InnerText = Convert.toRU(xmlNode.ChildNodes.Item(i).InnerText);               
                }
            }
            xmlDoc.Save(OutputFile);
        }   
    }
    
    public static class Convert 
    {           
        public static String toRU(String str)
        {
            String newStr = "";
            int i = 0;
            str = str.Replace("Ю", "Ю");
            str = str.Replace("й", "й");        
            while (i < str.Length)
            {            
                newStr += getCharRU(str[i]);
                i++;
            }
            return newStr;
        }   
        static Char getCharRU(Char ch)
        {
            switch (ch)
            {
                case '*': return '*';
                case '+': return '+';
                case ',': return ',';
                case '-': return '-';
                case '.': return '.';
                case '/': return '/';
                case '0': return '0';
                case '1': return '1';
                case '2': return '2';
                case '3': return '3';
                case '4': return '4';
                case '5': return '5';
                case '6': return '6';
                case '7': return '7';
                case '8': return '8';
                case '9': return '9';
                case ':': return ':';
                case ';': return ';';
                case '<': return '<';
                case '=': return '=';
                case '>': return '>';
                case '?': return '?';
                case '@': return '@';
                case 'A': return 'A';
                case 'B': return 'B';
                case 'C': return 'C';
                case 'D': return 'D';
                case 'E': return 'E';
                case 'F': return 'F';
                case 'G': return 'G';
                case 'H': return 'H';
                case 'I': return 'I';
                case 'J': return 'J';
                case 'K': return 'K';
                case 'L': return 'L';
                case 'M': return 'M';
                case 'N': return 'N';
                case 'O': return 'O';
                case 'P': return 'P';
                case 'Q': return 'Q';
                case 'R': return 'R';
                case 'S': return 'S';
                case 'T': return 'T';
                case 'U': return 'U';
                case 'V': return 'V';
                case 'W': return 'W';
                case 'X': return 'X';
                case 'Y': return 'Y';
                case 'Z': return 'Z';
                case '[': return '[';
                case '\\': return '\\';
                case ']': return ']';
                case '^': return '^';
                case '_': return '_';
                case '`': return '`';
                case 'a': return 'a';
                case 'b': return 'b';
                case 'c': return 'c';
                case 'd': return 'd';
                case 'e': return 'e';
                case 'f': return 'f';
                case 'g': return 'g';
                case 'h': return 'h';
                case 'i': return 'i';
                case 'j': return 'j';
                case 'k': return 'k';
                case 'l': return 'l';
                case 'm': return 'm';
                case 'n': return 'n';
                case 'o': return 'o';
                case 'p': return 'p';
                case 'q': return 'q';
                case 'r': return 'r';
                case 's': return 's';
                case 't': return 't';
                case 'u': return 'u';
                case 'v': return 'v';
                case 'w': return 'w';
                case 'x': return 'x';
                case 'y': return 'y';
                case 'z': return 'z';
                case '{': return '{';
                case '|': return '|';
                case '}': return '}';
                case '~': return '~';
                case '': return '';
                case 'Ç': return 'А';
                case 'ü': return 'Б';
                case 'é': return 'В';
                case 'â': return 'Г';
                case 'ä': return 'Д';
                case 'à': return 'Е';
                case 'å': return 'Ж';
                case 'ç': return 'З';
                case 'ê': return 'И';
                case 'ë': return 'Й';
                case 'è': return 'К';
                case 'ï': return 'Л';
                case 'î': return 'М';
                case 'ì': return 'Н';
                case 'Ä': return 'О';
                case 'Å': return 'П';
                case 'É': return 'Р';
                case 'æ': return 'С';
                case 'Æ': return 'Т';
                case 'ô': return 'У';
                case 'ö': return 'Ф';
                case 'ò': return 'Х';
                case 'û': return 'Ц';
                case 'ù': return 'Ч';
                case 'ÿ': return 'Ш';
                case 'Ö': return 'Щ';
                case 'Ü': return 'Ъ';
                case '¢': return 'Ы';
                case '£': return 'Ь';
                case '¥': return 'Э';
                case 'ƒ': return 'Я';
                case 'á': return 'а';
                case 'í': return 'б';
                case 'ó': return 'в';
                case 'ú': return 'г';
                case 'ñ': return 'д';
                case 'Ñ': return 'е';
                case 'ª': return 'ж';
                case 'º': return 'з';
                case '¿': return 'и';
                case '¬': return 'к';
                case '½': return 'л';
                case '¼': return 'м';
                case '¡': return 'н';
                case '«': return 'о';
                case '»': return 'п';
                case '': return 'Ђ';
                case '‚': return '¦';
                case '„': return 'Ѓ';
                case '…': return '‚';
                case '†': return 'ѓ';
                case '‡': return '„';
                case 'ˆ': return '…';
                case '‰': return '†';
                case 'Š': return '‡';
                case '‹': return '€';
                case 'Œ': return '‰';
                case '': return 'Љ';
                case 'Ž': return '‹';
                case '': return '¬';
                case '': return 'Њ';
                case '‘': return 'Ќ';
                case '’': return 'Ћ';
                case '“': return 'Џ';
                case '”': return 'ђ';
                case '•': return '‘';
                case '–': return '’';
                case '—': return '“';
                case '˜': return '”';
                case '™': return '•';
                case 'š': return '–';
                case '›': return '—';
                case 'œ': return '&#152;';
                case '': return '™';
                case 'ž': return 'љ';
                case 'Ÿ': return '›';
                case '¨': return 'њ';
                case '©': return 'ќ';
                case '­': return 'ћ';
                case '®': return 'џ';
                case '¯': return 'Ј';
                case '³': return 'Ґ';
                case '´': return '©';
                case '¸': return '«';
                case '¹': return '­';
                case '¾': return '®';
                case 'À': return '±';
                case 'Á': return 'І';
                case '': return 'і';
                case '¦': return 'ґ';
                case 'Ã': return 'µ';
                case 'È': return '»';
                case 'Ê': return 'р';
                case 'ß': return 'с';
                case 'Ë': return 'т';
                case 'Ì': return 'у';
                case 'Í': return 'ф';
                case 'Î': return 'х';
                case 'µ': return 'ц';
                case 'Ï': return 'ч';
                case 'Ð': return 'ш';
                case 'Ò': return 'щ';
                case 'Ó': return 'ъ';
                case 'Ô': return 'ы';
                case 'Õ': return 'ь';
                case '×': return 'э';
                case 'Ø': return 'ю';
                case 'Ù': return 'я';
                case 'Ú': return 'Ё';
                case '±': return 'ё';
                case 'Û': return 'Є';
                case 'Ý': return 'є';
                case 'Þ': return 'Ї';
                case 'ã': return 'ї';
                case '÷': return 'Ў';
                case 'ð': return 'ў';
                case '°': return '°';
                case 'õ': return 'ј';
                case '·': return '·';
                case 'ø': return 'Ѕ';
                case 'ý': return '№';
                case '²': return '¤';
                case 'þ': return 'ѕ';
    
            }
            return ch;        
        }
    }
    
    Navision developer
Sign In or Register to comment.