Merge pull request #5668 from kumpera/wasm-work-p4
[mono.git] / tools / locale-builder / TextInfoEntry.cs
index f7a04b5613ca010e40d83a92efeaaf13b85f9b8d..01fd9ccdd55ce5d96333b26fd9295bceda981956 100644 (file)
@@ -1,49 +1,62 @@
-using System;
-using System.Text;
-using System.Collections;
-using System.Xml;
-using System.Xml.XPath;
+//
+// TextInfoEntry.cs
+//
+// Authors:
+//     Marek Safar  <marek.safar@gmail.com>
+//
+// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
 
-namespace Mono.Tools.LocaleBuilder {
+using System.Text;
 
-        public class TextInfoEntry : Entry {
-               
-               string ansi = "0";
-               string ebcdic = "0";
-               string mac = "0";
-               string oem = "0";
-               string listsep = ",";
+namespace Mono.Tools.LocaleBuilder
+{
+       public class TextInfoEntry : Entry
+       {
+               public string ANSICodePage;
+               public string EBCDICCodePage;
+               public string MacCodePage;
+               public string OEMCodePage;
+               public string ListSeparator;
+               public bool IsRightToLeft;
 
-               public TextInfoEntry (int lcid, XPathDocument d)
+               public override string ToString ()
                {
-                       string q = "/textinfos/textinfo [@lcid=" + lcid + "]";
-                       XPathNodeIterator ni = (XPathNodeIterator) d.CreateNavigator ().Evaluate (q);
-                       // no info, move along
-                       if (! ni.MoveNext ())
-                               throw new Exception ();         
-                       
-                       ansi = ni.Current.GetAttribute ("ansi", String.Empty);
-                       ebcdic = ni.Current.GetAttribute ("ebcdic", String.Empty);
-                       mac = ni.Current.GetAttribute ("mac", String.Empty);
-                       oem = ni.Current.GetAttribute ("oem", String.Empty);
-                       listsep = ni.Current.GetAttribute ("listsep", String.Empty);
-               }
-               
-                public override string ToString ()
-                {
                        StringBuilder b = new StringBuilder ();
                        b.Append ("{ ");
-                       b.Append (ansi);
-                       b.Append (", ");
-                       b.Append (ebcdic);
-                       b.Append (", ");
-                       b.Append (mac );
-                       b.Append (", ");
-                       b.Append (oem);
-                       b.Append (", '");
-                       b.Append (listsep);
+                       b.Append (ANSICodePage).Append (", ");
+                       b.Append (EBCDICCodePage).Append (", ");
+                       b.Append (MacCodePage).Append (", ");
+                       b.Append (OEMCodePage).Append (", ");
+                       b.Append (IsRightToLeft ? "1" : "0").Append (", '");
+
+                       // TODO: It's more than 1 char for some cultures
+                       if (ListSeparator.Length <= 1)
+                               b.Append (ListSeparator);
+                       else
+                               b.Append (";");
+
                        b.Append ("' }");
-                       
+
                        return b.ToString ();
                }
        }