+2004-06-18 Atsushi Enomoto <atsushi@ximian.com>
+
+ * DTDObjectModel.cs, DTDReader.cs, XmlConvert.cs, XmlDocument.cs,
+ XmlException.cs, XmlParserInput.cs, XmlTextReader.cs,
+ XmlTextWriter.cs : Globalization.
+ * XmlNode.cs : Fixed error message that confused node type.
+
2004-06-14 Atsushi Enomoto <atsushi@ximian.com>
* XmlDocumentNavigator.cs : MoveToNext() should skip concatenating
resolvedNormalizedDefaultValue =
(o is string []) ?
String.Join (" ", (string []) o) :
- o.ToString ();
+ o is IFormattable ? ((IFormattable) o).ToString (null, CultureInfo.InvariantCulture) : o.ToString ();
} catch (Exception) {
// This is for non-error-reporting reader
resolvedNormalizedDefaultValue = Datatype.Normalize (s);
}
else
spec = value.Substring (next + 2, semicolon - next - 2);
- sb.Append ((char) int.Parse (spec, style));
+ sb.Append ((char) int.Parse (spec, style, CultureInfo.InvariantCulture));
} else {
sb.Append (value.Substring (pos, next - 1));
string name = value.Substring (next + 1, semicolon - 2);
int ret = 0;
if (value [index] == 'x') {
try {
- ret = int.Parse (value.Substring (index + 1, end - index - 1), NumberStyles.HexNumber);
+ ret = int.Parse (value.Substring (index + 1, end - index - 1), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
} catch (FormatException) {
throw new XmlException (li, "Invalid number for a character reference.");
}
} else {
try {
- ret = int.Parse (value.Substring (index, end - index));
+ ret = int.Parse (value.Substring (index, end - index), CultureInfo.InvariantCulture);
} catch (FormatException) {
throw new XmlException (li, "Invalid number for a character reference.");
}
return; // do nothing
}
// FIXME: These leading/trailing ' ' is anyways supplied inside this method!
- currentInput.InsertParameterEntityBuffer (" " + peDecl.ReplacementText + " ");
+// currentInput.InsertParameterEntityBuffer (" " + peDecl.ReplacementText + " ");
+ currentInput.InsertParameterEntityBuffer (peDecl.ReplacementText);
}
// The reader is positioned on the head of the name.
if (ch != expected) {
throw new XmlException (this as IXmlLineInfo,
- String.Format (
+ String.Format (CultureInfo.InvariantCulture,
"expected '{0}' ({1:X}) but found '{2}' ({3:X})",
(char) expected,
expected,
if (XmlChar.IsWhitespace (i))
continue;
if (c != i)
- throw new XmlException (this, String.Format ("Expected {0} but found {1} [{2}].", c, (char) i, i));
+ throw new XmlException (this, String.Format (CultureInfo.InvariantCulture, "Expected {0} but found {1} [{2}].", c, (char) i, i));
break;
}
}
else
throw new XmlException (this as IXmlLineInfo,
String.Format (
+ CultureInfo.InvariantCulture,
"invalid hexadecimal digit: {0} (#x{1:X})",
(char) ch,
ch));
else
throw new XmlException (this as IXmlLineInfo,
String.Format (
+ CultureInfo.InvariantCulture,
"invalid decimal digit: {0} (#x{1:X})",
(char) ch,
ch));
char c = '\uFFFF';
try {
- c = (char) Int32.Parse (s.Substring (1, 4), NumberStyles.HexNumber);
+ c = (char) Int32.Parse (s.Substring (1, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
} catch {
return s [0] + DecodeName (s.Substring (1));
}
if (!Char.IsDigit (s [i]))
break;
}
- int value = int.Parse (s.Substring (start, i - start));
+ int value = int.Parse (s.Substring (start, i - start), CultureInfo.InvariantCulture);
switch (s [i]) {
case 'Y':
days += value * 365;
//
using System;
+using System.Globalization;\r
using System.IO;
using System.Text;
using System.Xml.XPath;
{
IXmlLineInfo li = reader as IXmlLineInfo;
if (li != null)
- return String.Format ("{0} Line number = {1}, Inline position = {2}.", message, li.LineNumber, li.LinePosition);
+ return String.Format (CultureInfo.InvariantCulture, "{0} Line number = {1}, Inline position = {2}.", message, li.LineNumber, li.LinePosition);
else
return message;
}
//
using System;
+using System.Globalization;\r
using System.Runtime.Serialization;
namespace System.Xml
if (lineNumber == 0)
return base.Message;
- return String.Format ("{0} Line {1}, position {2}.",
+ return String.Format (CultureInfo.InvariantCulture, "{0} Line {1}, position {2}.",
base.Message, lineNumber, linePosition);
}
}
NodeType != XmlNodeType.Attribute &&
NodeType != XmlNodeType.Document &&
NodeType != XmlNodeType.DocumentFragment)
- throw new InvalidOperationException (String.Format ("Node cannot be appended to current node " + NodeType + "."));
+ throw new InvalidOperationException (String.Format ("Node cannot be appended to current node {0}.", NodeType));
switch (NodeType) {
case XmlNodeType.Attribute:
break;
default:
throw new InvalidOperationException (String.Format (
- "Cannot insert specified type of node {0} as a child of this node {0}.",
+ "Cannot insert specified type of node {0} as a child of this node {1}.",
newChild.NodeType, NodeType));
}
break;
\r
if (ch != expected) {\r
throw ReaderError (\r
- String.Format (\r
+ String.Format (CultureInfo.InvariantCulture, \r
"expected '{0}' ({1:X}) but found '{2}' ({3:X})",\r
(char)expected,\r
expected,\r
int ret = -1;\r
if (name.Length > 0 && name [0] == '#') {\r
if (name [1] == 'x')\r
- ret = int.Parse (name.Substring (2, name.Length - 2), NumberStyles.None & NumberStyles.AllowHexSpecifier);\r
+ ret = int.Parse (name.Substring (2, name.Length - 2), NumberStyles.None & NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture);\r
else\r
- ret = int.Parse (name.Substring (1, name.Length - 1));\r
+ ret = int.Parse (name.Substring (1, name.Length - 1), CultureInfo.InvariantCulture);\r
}\r
return ret;\r
}\r
using System;
using System.Collections;
+using System.Globalization;\r
using System.IO;
using System.Security.Policy;
using System.Text;
value = (value << 4) + ch - 'a' + 10;
else
throw new XmlException (this as IXmlLineInfo,
- String.Format (
+ String.Format (CultureInfo.InvariantCulture,
"invalid hexadecimal digit: {0} (#x{1:X})",
(char) ch,
ch));
value = value * 10 + ch - '0';
else
throw new XmlException (this as IXmlLineInfo,
- String.Format (
+ String.Format (CultureInfo.InvariantCulture,
"invalid decimal digit: {0} (#x{1:X})",
(char) ch,
ch));
if (target == "xml") {
ReadXmlDeclaration ();
return;
- } else if (target.ToLower () == "xml")
+ } else if (target.ToLower (CultureInfo.InvariantCulture) == "xml")
throw new XmlException (this as IXmlLineInfo,
"Not allowed processing instruction name which starts with 'X', 'M', 'L' was found.");
ReadChar ();
}
if (new string (peekChars, 2, 4) != "xml ") {
- if (new string (peekChars, 2, 3).ToLower () == "xml") {
+ if (new string (peekChars, 2, 3).ToLower (CultureInfo.InvariantCulture) == "xml") {
throw new XmlException (this as IXmlLineInfo,
"Processing instruction name must not be character sequence 'X' 'M' 'L' with case insensitivity.");
}
{
int ch = PeekChar ();
if (!XmlChar.IsFirstNameChar (ch))
- throw new XmlException (this as IXmlLineInfo,String.Format ("a name did not start with a legal character {0} ({1})", ch, (char) ch));
+ throw new XmlException (this as IXmlLineInfo,String.Format (CultureInfo.InvariantCulture, "a name did not start with a legal character {0} ({1})", ch, (char) ch));
nameLength = 0;
if (ch != expected) {
throw new XmlException (this as IXmlLineInfo,
- String.Format (
+ String.Format (CultureInfo.InvariantCulture,
"expected '{0}' ({1:X}) but found '{2}' ({3:X})",
(char) expected,
expected,
if (i < 0x21 && XmlChar.IsWhitespace (i))
continue;
if (c != i)
- throw new XmlException (this, String.Join (String.Empty, new string [] {"Expected ", c.ToString (), ", but found " + (char) i, "[", i.ToString (), "]"}));
+ throw new XmlException (this, String.Format (CultureInfo.InvariantCulture, "Expected {0}, but found {1} [{2}]", c, (char) i, i));
break;
}
}
//
using System;
using System.Collections;
+using System.Globalization;\r
using System.IO;
using System.Text;
localName = prefix;
prefix = String.Empty;
}
- else if (localName.ToLower ().StartsWith ("xml"))
+ else if (localName.ToLower (CultureInfo.InvariantCulture).StartsWith ("xml"))
throw new ArgumentException ("Prefixes beginning with \"xml\" (regardless of whether the characters are uppercase, lowercase, or some combination thereof) are reserved for use by XML: " + prefix + ":" + localName);
}
if (pos < 0) {
cachedStringBuilder.Append ("&#x");
if (invalid < (char) 255)
- cachedStringBuilder.Append (((int) invalid).ToString ("X02"));
+ cachedStringBuilder.Append (((int) invalid).ToString ("X02", CultureInfo.InvariantCulture));
else
- cachedStringBuilder.Append (((int) invalid).ToString ("X04"));
+ cachedStringBuilder.Append (((int) invalid).ToString ("X04", CultureInfo.InvariantCulture));
cachedStringBuilder.Append (";");
}
else
}
w.Write ("&#x");
- w.Write (((int) ((highChar - 0xD800) * 0x400 + (lowChar - 0xDC00) + 0x10000)).ToString ("X"));
+ w.Write (((int) ((highChar - 0xD800) * 0x400 + (lowChar - 0xDC00) + 0x10000)).ToString ("X", CultureInfo.InvariantCulture));
w.Write (';');
}