Skip to content

Commit 920d833

Browse files
xemed-ahopeMikeRayMSFT
authored andcommitted
Reword CHAR() example G
Reword example G description again. Conversion doesn't necessarily entail decoding. Revert edits to the wording @pmasl provided. Fix example output
1 parent b4a09f2 commit 920d833

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

docs/t-sql/functions/char-transact-sql.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ single_byte_representing_complete_character single_byte_representing_complete_ch
184184
### F. Using CHAR to return multibyte characters
185185
This example uses integer and hex values in the valid range for Extended ASCII.
186186
However, the `CHAR` function returns `NULL` because the parameter represents only the first byte of a multibyte character.
187-
A **char(2)** double-byte character can neither be partially represented nor be divided without some conversion operation.
188-
The individual bytes of a double-byte character don't generally represent valid **char(1)** values.
187+
A CHAR(2) double-byte character cannot be partially represented nor divided without some conversion operation.
188+
The individual bytes of a double-byte character don't generally represent valid CHAR(1) values.
189189

190190
```sql
191191
SELECT CHAR(129) AS first_byte_of_double_byte_character,
@@ -201,12 +201,10 @@ first_byte_of_double_byte_character first_byte_of_double_byte_character
201201
NULL NULL
202202
```
203203

204-
### G. Using CONVERT instead of CHAR to decode multibyte characters
205-
This example relies on the default codepage of the current database to decode a multibyte character.
206-
`CONVERT` here operates on a character encoding, SHIFT\_JIS.
207-
`CHAR` and `NCHAR` operate on character sets and codepoints,
208-
which works well with ASCII code 13 above, but not with JIS X 208 code 2-86 here.
209-
Encoding JIS X 208 ku-ten codes to SHIFT\_JIS is outside the scope of this example.
204+
### G. Using CONVERT instead of CHAR to return multibyte characters
205+
This example accepts the binary value as an encoded multibyte character consistent with the default codepage of the current database,
206+
subject to validation.
207+
Character conversion is more broadly supported and may be an alternative to working with encoding at a lower level.
210208

211209
```sql
212210
CREATE DATABASE [multibyte-char-context]
@@ -222,9 +220,9 @@ SELECT NCHAR(0x266A) AS [eighth-note]
222220
[!INCLUDE[ssResult](../../includes/ssresult-md.md)]
223221

224222
```
225-
eighth-note context-dependent-convert context-dependent-cast
226-
----------- ------------------------- ----------------------
227-
223+
codepoint encoded to char bytes decoded to char
224+
------------------------- ---------------------
225+
♪ ♪
228226
```
229227

230228
### H. Using NCHAR instead of CHAR to look up UTF-8 characters

0 commit comments

Comments
 (0)