SoundexSimilar
Function SoundexSimilar( const AText, AOther : string; ALength : TSoundexLength) : Boolean
Example
procedure ScriptEvent(var Value: variant);
begin
Value := SoundexSimilar('Robert', 'Rupert', 4);
end;
Usage
SoundexSimilar reports whether two strings produce exactly equal Soundex codes at the requested length.
Parameters
| Name | Type | Description |
|---|---|---|
AText | string, const | First text to encode. |
AOther | string, const | Second text to encode. |
ALength | TSoundexLength | Requested code length. Velox exposes this reference as LongInt; validate it before calling. |
Returns
True when Soundex(AText, ALength) = Soundex(AOther, ALength); otherwise False.
Behaviour
The function is a grouping predicate. It answers whether the codes collide, not whether the source strings are identical, valid names or the same real-world entity.
Errors
Normal bounded inputs have no expected exception. Excessive length can raise an allocation/length error; invalid lengths can produce nonstandard codes without a validation exception.
Usage notes
Use this only as one candidate-matching signal. Confirm identity with authoritative fields and business rules. Use ResemblesText only when the host-configurable procedure indirection is intended.
Additional Technical Info
SoundexSimilar generates a Soundex code for each input at the requested length and returns exact code equality.
The example returns True because both codes are R163. It is source-reviewed and is not executed by the documentation workflow.
Implementation
Velox binds directly to System.StrUtils.SoundexSimilar. Current Delphi source calls Soundex twice and compares the managed result strings case-sensitively. Because normal generated codes are canonical uppercase/digit strings, no additional case fold is needed.
Edge cases and quirks
- Two empty strings return
Truebecause both codes are empty. One empty and one non-empty string returnFalse. - All
Soundexrules are inherited: ASCII-focused scoring, retained first character, no normalisation, invalid script lengths and the length-one bug. - Shorter requested lengths increase collisions. Increasing length can distinguish more later consonant groups but does not make Soundex language-neutral or unique.
- Non-Latin or punctuation-heavy values can produce weak codes and misleading
Trueresults. - A very large positive length can allocate large zero-padded codes twice before comparison.
Side effects
None. Two temporary result strings are allocated.
Performance and concurrency
Work is linear in both inputs up to code completion, plus comparison proportional to the generated code length. There is no shared mutable state.
Related entries
Soundexreturns each code for inspection.SoundexComparereturns the code ordering.ResemblesTextnormally uses four-character Soundex through a configurable procedure.
External references
- Embarcadero
System.StrUtils.SoundexSimilar - Free Pascal
SoundexSimilar- compatibility context; current DelphiSoundexsource defines Velox's exact code equality.