Created
February 14, 2012 18:09
-
-
Save kumpera/1828685 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
unsafe class Driver { | |
private unsafe static byte *category_data; | |
[MethodImpl (MethodImplOptions.AggressiveInlining)] | |
public static bool IsWhiteSpace (char c) | |
{ | |
unsafe { | |
int category = category_data [c]; | |
if (category <= ((int)UnicodeCategory.OtherNumber)) | |
return false; | |
if (category <= ((int)UnicodeCategory.ParagraphSeparator)) | |
return true; | |
// FIXME: (char)0x205F Medium Mathematical Space has wrong category in 2.0 Profile | |
// Remove the if NET_2_0 case once the error is corrected | |
return c >= (char)0x09 && c <= (char)0x0d || c == (char)0x85 || c == (char)0x205F; | |
} | |
} | |
static void Main () { | |
Console.WriteLine (IsWhiteSpace (' ')); | |
Console.WriteLine (IsWhiteSpace ('x')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment