utf 8 - Get difference between two character codes in Ruby -
although might not readable, hoping can tell me if possible - , if how - make following code work
true if (string1 - string2) == predefined_distance
i hope might possible using ruby's open classes, looking @ documentation utf-8 , encoder::converter
i'm not sure if it's possible do more <=>
isn't @ precise. perhaps can convert ascii , compare values?
an example of use might compare 2 opening closing brackets, see if match instead of defining separate lists or containers each type of bracket, , instead can define distance 2 arbitrary characters.
built-in method ord
of string class can return number of character:
true if (string1.chars.first.ord - string2.chars.first.ord) == predefined_distance
Comments
Post a Comment