[20180503]Shen and separator.txt

[20180503]Shen and separator.txt

--//I encountered the problem of separator again today, and I have encountered it once before, link.http://blog.itpub.net/267265/viewspace-763696/
--/ /This "Shen" is still used as a name by many people..

$ cat d1.txt
123|Zhang Feishen test|aaa1

$ cat d1.txt | tr '|' '\n'
123
Zhang Fei?
test
aaa1

--//This way It is divided into 4 fields, resulting in an error.

$ echo Shen| xxd -c 16
-bash: syntax error near unexpected token `|'

--//Because the "Shen" encoding contains the character "|", an error occurs. Use quotation marks

$ echo -n "Shen" | xxd -c 16
0000000: ab7c .|

--//The encoding of "Shen" is ab7c, and the encoding of 7c is "|".

$ echo -n "|" | xxd -c 16
0000000: 7c |

--//This causes segmentation errors. In fact, this character does not belong to the GB2312 encoding table.
--//Previously located by this script:
select upper(TO_CHAR (167+rownum,'xxxxxxxxxxxx')) "10to16",chr(167+rownum)||'|' from dual connect by level+167<=254;
--//But only for database character set AMERICAN_AMERICA.US7ASCII is valid.
--//For character set AMERICAN_AMERICA.ZHS16GBK, the following query can be used:

SELECT hex, UTL_RAW.cast_to_varchar2 (hex) hz
  FROM ( SELECT TO_CHAR (167 + ROWNUM, 'FMxx') || '7c' hex
              FROM DUAL
        CONNECT BY LEVEL + 167 <= 254);



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325260660&siteId=291194637