سؤال

Does the newline sequence or even all escape sequences in a file count as only one character, even though it's written \n?

After I separated a one-line-file into multiple lines, only one character per line was added according to the wc -m output of the terminal.

هل كانت مفيدة؟

المحلول

\n is a way of representing a newline character in various languages and programs but as the name suggests, a newline is only stored in a file as a single character.

The backslash helps both computers and humans to realise you are referring to a newline character without you having to actually type one, which would be confusing in a lot of instances.

نصائح أخرى

The \n notation is usually used for a single character. Use a hexdump to see the actual bytes, for example xxd.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top