DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | List of all members
Deveel.Data.Text.Soundex.DefaultSoundex Class Reference
Inheritance diagram for Deveel.Data.Text.Soundex.DefaultSoundex:
Deveel.Data.Text.Soundex

Public Member Functions

override string Compute (string s)
 
- Public Member Functions inherited from Deveel.Data.Text.Soundex
virtual int Difference (string s1, string s2)
 

Additional Inherited Members

- Static Public Attributes inherited from Deveel.Data.Text.Soundex
static Soundex Default = new DefaultSoundex()
 
- Protected Member Functions inherited from Deveel.Data.Text.Soundex
virtual string EncodeChar (char c)
 

Detailed Description

Definition at line 64 of file Soundex.cs.

Member Function Documentation

override string Deveel.Data.Text.Soundex.DefaultSoundex.Compute ( string  s)
inlinevirtual

Implements Deveel.Data.Text.Soundex.

Definition at line 65 of file Soundex.cs.

65  {
66  if (String.IsNullOrEmpty(s))
67  return String.Empty;
68 
69  int startIndex;
70  for (startIndex = 0; startIndex < s.Length && !char.IsLetter(s[startIndex]); startIndex++) {
71  }
72 
73  if (startIndex >= s.Length)
74  return String.Empty;
75 
76  var output = new StringBuilder();
77 
78  output.Append(Char.ToUpperInvariant(s[startIndex]));
79 
80  // Stop at a maximum of 4 characters.
81  for (int i = startIndex + 1; i < s.Length && output.Length < 4; i++) {
82  string c = EncodeChar(s[i]);
83 
84  // Ignore duplicated chars.
85  if (c != EncodeChar(s[i - 1])) {
86  output.Append(c);
87  }
88  }
89 
90  // Pad with zeros.
91  output.Append(new String('0', 4 - output.Length));
92 
93  return output.ToString();
94  }
A long string in the system.
virtual string EncodeChar(char c)
Definition: Soundex.cs:31

The documentation for this class was generated from the following file: