3 namespace Lucene
.Net
.Analysis
.Ru
5 /* ====================================================================
6 * The Apache Software License, Version 1.1
8 * Copyright (c) 2001 The Apache Software Foundation. All rights
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in
20 * the documentation and/or other materials provided with the
23 * 3. The end-user documentation included with the redistribution,
24 * if any, must include the following acknowledgment:
25 * "This product includes software developed by the
26 * Apache Software Foundation (http://www.apache.org/)."
27 * Alternately, this acknowledgment may appear in the software itself,
28 * if and wherever such third-party acknowledgments normally appear.
30 * 4. The names "Apache" and "Apache Software Foundation" and
31 * "Apache Lucene" must not be used to endorse or promote products
32 * derived from this software without prior written permission. For
33 * written permission, please contact apache@apache.org.
35 * 5. Products derived from this software may not be called "Apache",
36 * "Apache Lucene", nor may "Apache" appear in their name, without
37 * prior written permission of the Apache Software Foundation.
39 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
40 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
41 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
46 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
47 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
48 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
49 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * ====================================================================
53 * This software consists of voluntary contributions made by many
54 * individuals on behalf of the Apache Software Foundation. For more
55 * information on the Apache Software Foundation, please see
56 * <http://www.apache.org/>.
60 /// RussianCharsets class contains encodings schemes (charsets) and ToLowerCase() method implementation
61 /// for russian characters in Unicode, KOI8 and CP1252.
62 /// Each encoding scheme contains lowercase (positions 0-31) and uppercase (position 32-63) characters.
63 /// One should be able to add other encoding schemes (like ISO-8859-5 or customized) by adding a new charset
64 /// and adding logic to ToLowerCase() method for that charset.
66 /// <author>Boris Okner, b.okner@rogers.com</author>
67 /// <version>$Id: RussianCharsets.cs,v 1.1.1.1 2004/04/29 22:53:51 trow Exp $</version>
68 public class RussianCharsets
71 /// Unicode Russian charset (lowercase letters only)
73 public static char[] UnicodeRussian
= {
144 public static char[] KOI8
= {
215 public static char[] CP1251
= {
283 public static char ToLowerCase(char letter
, char[] charset
)
285 if (charset
== UnicodeRussian
)
287 if (letter
>= '\u0430' && letter
<= '\u044F')
291 if (letter
>= '\u0410' && letter
<= '\u042F')
293 return (char) (letter
+ 32);
299 if (letter
>= 0xe0 && letter
<= 0xff)
301 return (char) (letter
- 32);
303 if (letter
>= 0xc0 && letter
<= 0xdf)
310 if (charset
== CP1251
)
312 if (letter
>= 0xC0 && letter
<= 0xDF)
314 return (char) (letter
+ 32);
316 if (letter
>= 0xE0 && letter
<= 0xFF)
323 return Char
.ToLower(letter
);