What characters do LTRIM and RTRIM trim exactly?

前端 未结 1 1327
终归单人心
终归单人心 2021-01-21 04:41

LTRIM and RTRIM are documented to trim \"blanks\". What characters are considered \"blank\" exactly?

相关标签:
1条回答
  • 2021-01-21 05:24

    Good question. Although there are many whitespace characters defined in Unicode, only a space (0x0020) is removed:

    with Characters as (
      select NChar( 0 ) as Character
      union all
      select NChar( Unicode( Character ) + 1 )
        from Characters
        where Unicode( Character ) < 65535 ),
      CharacterMap as (
      select Unicode( Character ) as [UnicodePoint], Character,
        1 - Len( LTrim( Character ) ) as [Whitespace]
        from Characters )
      select UnicodePoint, Character, Whitespace
        from CharacterMap
        where Whitespace = 1
        option ( MaxRecursion 0 );
    

    (The same applies to RTrim.)

    0 讨论(0)
提交回复
热议问题