3.1.5.2.10 GetExpansionWeights

This algorithm specifies the generation of a character weight for the specified character that has the expansion behavior, as defined in [UNICODE-COLLATION] section 3.2.

 COMMENT GetExpansionWeights
 COMMENT
 COMMENT  On Entry:  SourceCharacter - Character to look up
 COMMENT                               expansions for
 COMMENT             SortLocale      - Locale to get sort weights for
 COMMENT
 COMMENT  On Exit:   Weights         - String of 2 or 3 weights for
 COMMENT                               this character
 COMMENT
  
 PROCEDURE GetExpansionWeights(IN SourceCharacter : Unicode Character,
                             IN SortLocale : LCID,
                             OUT Weights : CharacterWeightType String)
  
 SET Weights to new empty string of CharacterWeightType
 SET ExpandedCharacters to CALL GetExpandedCharacters WITH
                   (SourceCharacter)
  
 // Append first weight
 SET Weight to CALL GetCharacterWeights WITH
                   (SortLocale, ExpandedCharacters[0])
 APPEND Weight to Weights
  
 // Get second weight, it might expand again
 SET Weight to CALL GetCharacterWeights WITH
                   (SortLocale, ExpandedCharacters[1])
  
 IF Weight.ScriptMember is EXPANSION THEN
     // second weight expands again, get new expansion
     // note that this can only happen once, as it does
     // with the U=fb03 (ffi ligature)
  
     SET ExpandedCharacters to CALL
                   GetExpandedCharacters(ExpandedCharacters[1])
  
     // Append second expansion's first weight
     SET Weight to CALL GetCharacterWeights WITH
                   (SortLocale, ExpandedCharacters[0])
     APPEND Weight to Weights
  
     // Get second weight for second expansion, it will not expand again
     SET Weight to CALL GetCharacterWeights WITH
                   (SortLocale, ExpandedCharacters[1])
 ENDIF
  
 // Finish appending second weight to weights string
 APPEND Weight to Weights
  
 RETURN Result