Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/694305e8-d7f8-800e-a8d8-fbf410be6545
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Assistant: 半角の \(バックスラッシュ) は、言語・環境・フォントによって「見た目」と「意味」が結構変わるのでややこしいやつです。 === 半角の <code>\</code>(バックスラッシュ) は、言語・環境・フォントによって「見た目」と「意味」が結構変わるのでややこしいやつです。 整理して説明します。 ==== ### ==== * 表示: ¥(円マーク) * 実体:ASCIIコード 0x5C(= バックスラッシュ) 👉 見た目が ¥ でも 中身は <code>\</code> これは歴史的な日本独自仕様。 例(Windows 日本語フォント) <syntaxhighlight>C:\Users\Name ↓ 見た目 C:¥Users¥Name </syntaxhighlight> ===== - 表示: \ ===== * 実体:同じく ASCII 0x5C <syntaxhighlight>/home/user C:\Users\Name ← バックスラッシュは普通に \ 表示 </syntaxhighlight> ===== 同じコードでもフォントで変わる: ===== * MS ゴシック → ¥ * Consolas / Menlo / Source Code Pro → \ ==== ### ==== \ は エスケープ文字 ===== <syntaxhighlight lang="c">\n // 改行 ===== \t // タブ \" // ダブルクォート \\ // バックスラッシュそのもの </syntaxhighlight> 例(Python) <syntaxhighlight lang="python">print("C:\\Users\\Name") </syntaxhighlight> ===== \ は メタ文字のエスケープ ===== <syntaxhighlight lang="regex">\d // 数字 \w // 英数字 \. // ピリオドそのもの </syntaxhighlight> ===== - 区切り文字として使われる ===== <syntaxhighlight lang="text">C:\Windows\System32 </syntaxhighlight> ※ 内部的には \ ※ 表示が ¥ でも同じ ===== - 使わない ===== * 区切りは / <syntaxhighlight lang="text">/home/user </syntaxhighlight> ===== - 改行継続 ===== <syntaxhighlight lang="bash">echo hello \ world </syntaxhighlight> * エスケープ <syntaxhighlight lang="bash">echo \$HOME </syntaxhighlight> ===== - コマンド開始文字 ===== <syntaxhighlight lang="tex">\section{Title} \alpha </syntaxhighlight> ==== ### ==== * 入力するときは 必ず <code>\</code> キー * ¥ をコピーすると別コードになることがある ===== - 円マークは存在しない ===== * すべて \ として処理される ==== | | | | ==== | --- | --- | --- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | もし * 特定の言語(Python / JavaScript / バッチ / PowerShell) * 文字コード(Shift-JIS / UTF-8) * なぜ <code>¥</code> になったのか歴史 を深掘りしたければ、そこも説明できるよ。
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)