Here the documentation from Escape Sequences PHP.net (encoding the non-printing character (i.e SUB) to \cx for search pattern):
The precise effect of "\cx" is as follows: if "x" is a lower case letter, it is converted to upper case. Then bit 6 of the character (hex 40) is inverted. Thus "\cz" becomes hex 1A, but "\c{" becomes hex 3B, while "\c;" becomes hex 7B.
I'm kind of understand the conversion. I.e Z(1011010) the first 1 invert to 0 and give the result SUB(0011010). But isn't it should be bit 7 be inverted,not 6? And what hex 40(1000000) doing here? I know my consumption is wrong,i just really need your help. Thank you very much!
But isn't it should be bit 7 be inverted,not 6? And what hex 40(1000000) doing here?
These two questions are related to each other. The documentation is indicating the value that they mean by "bit 6".
Basically, they're using the common numbering system of "bit 0 is the least-significant bit". So the bits in a byte are bit 0 to bit 7.
Thus flipping bit 6 of a byte is basically a matter of taking the XOR of the byte with 0x40.
See more on this question at Stackoverflow