gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r11539 - Extractor-mono/LibExtractor/src


From: gnunet
Subject: [GNUnet-SVN] r11539 - Extractor-mono/LibExtractor/src
Date: Thu, 27 May 2010 17:54:17 +0200

Author: patrick
Date: 2010-05-27 17:54:17 +0200 (Thu, 27 May 2010)
New Revision: 11539

Modified:
   Extractor-mono/LibExtractor/src/Extractor.cs
Log:
* src/Extractor.cs: remove BOM markers from unicode keywords

Modified: Extractor-mono/LibExtractor/src/Extractor.cs
===================================================================
--- Extractor-mono/LibExtractor/src/Extractor.cs        2010-05-27 14:48:56 UTC 
(rev 11538)
+++ Extractor-mono/LibExtractor/src/Extractor.cs        2010-05-27 15:54:17 UTC 
(rev 11539)
@@ -1,6 +1,6 @@
 // Extractor.cs
 // 
-// Copyright (C) 2008, 2009 Patrick Ulbrich, address@hidden
+// Copyright (C) 2008 - 2010 Patrick Ulbrich, address@hidden
 //
 // This program is free software: you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -144,6 +144,9 @@
                                
                                while (p != IntPtr.Zero) {
                                        Keyword k = 
(Keyword)Marshal.PtrToStructure(p, typeof(Keyword));
+                                       
+                                       k.keyword = RemoveBOM(k.keyword);
+                                       
                                        list.Add(k);
                                        p = k.next;
                                }
@@ -320,6 +323,17 @@
                        return copy;
                }
                
+               // remove unicode byte ordering mark
+               private static string RemoveBOM(string s) {
+                       const char BOM_UTF16_BE = (char)0xFEFF;
+                       const char BOM_UTF16_LE = (char)0xFFFE;
+                       
+                       if (s[0] == BOM_UTF16_BE || s[0] == BOM_UTF16_LE)
+                               return s.Substring(1, s.Length -1);
+                       else
+                               return s;
+               }
+               
                /// 
                /// Cleanup stuff
                ///




reply via email to

[Prev in Thread] Current Thread [Next in Thread]