[gnome-subtitles] Use InvariantCulture when reading and writing files, wasn't working correctly for elapsed times
- From: Pedro Daniel da Rocha Melo e Castro <pcastro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-subtitles] Use InvariantCulture when reading and writing files, wasn't working correctly for elapsed times
- Date: Sun, 11 Sep 2011 21:37:28 +0000 (UTC)
commit 22fe72851ea74de02b64c83279abc1d5cf44926f
Author: Pedro Castro <pedro gnomesubtitles org>
Date: Sun Sep 11 22:20:20 2011 +0100
Use InvariantCulture when reading and writing files, wasn't working correctly for elapsed times
src/SubLib/IO/Input/SubtitleParser.cs | 7 +++++--
src/SubLib/IO/Output/SubtitleOutput.cs | 6 ++++--
2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/SubLib/IO/Input/SubtitleParser.cs b/src/SubLib/IO/Input/SubtitleParser.cs
index ef8adfe..db1823b 100644
--- a/src/SubLib/IO/Input/SubtitleParser.cs
+++ b/src/SubLib/IO/Input/SubtitleParser.cs
@@ -1,6 +1,6 @@
/*
* This file is part of SubLib.
- * Copyright (C) 2005-2009 Pedro Castro
+ * Copyright (C) 2005-2009,2011 Pedro Castro
*
* SubLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@ using SubLib.Core.Domain;
using SubLib.Core.Timing;
using SubLib.IO.SubtitleFormats;
using System;
+using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
@@ -496,8 +497,10 @@ internal class SubtitleParser {
string textResult = String.Empty;
bool returnValue = ParseGroup(match, groupName, ref textResult);
if (returnValue) {
+ textResult = textResult.Replace(',', '.');
+
try {
- result = (float)Convert.ToDouble(textResult);
+ result = (float)Convert.ToDouble(textResult, CultureInfo.InvariantCulture);
} catch (Exception) {
return false;
}
diff --git a/src/SubLib/IO/Output/SubtitleOutput.cs b/src/SubLib/IO/Output/SubtitleOutput.cs
index 5ceb07a..a53c63e 100644
--- a/src/SubLib/IO/Output/SubtitleOutput.cs
+++ b/src/SubLib/IO/Output/SubtitleOutput.cs
@@ -1,6 +1,6 @@
/*
* This file is part of SubLib.
- * Copyright (C) 2005-2010 Pedro Castro
+ * Copyright (C) 2005-2011 Pedro Castro
*
* SubLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@ using SubLib.Core.Timing;
using SubLib.IO.SubtitleFormats;
using System;
using System.Collections;
+using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
@@ -197,9 +198,10 @@ internal class SubtitleOutput {
}
private string FormatedField (double field) {
- return field.ToString("0.###");
+ return field.ToString("0.###", CultureInfo.InvariantCulture);
}
+ //TODO fix precision when saving files. If our number width is greater than 'width', some of the last digits will be removed
private string DimensionField (int field, int width) {
return field.ToString("D" + width).Substring(0, width);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]