Mac How do I type the ¦ character on mac keyboard?

brightside1863

macrumors newbie
Original poster
Oct 7, 2010
3
0
Nottinghamshire, UK
I'm teaching myself C and can't find how to type the ¦ symbol into xcode. If I copy and paste from a WP program xcode throws up an error when building the code.
I'm assuming that this is due to it being copied and pasted, unless xcode recognises another character as the OR bitwise operator?

Can anyone help?
 

robvas

macrumors 68040
Mar 29, 2009
3,072
529
USA
I'm teaching myself C and can't find how to type the ¦ symbol into xcode. If I copy and paste from a WP program xcode throws up an error when building the code.
I'm assuming that this is due to it being copied and pasted, unless xcode recognises another character as the OR bitwise operator?

Can anyone help?
Shift + the key above the return key?
 

gnasher729

Suspended
Nov 25, 2005
16,996
3,932
I'm teaching myself C and can't find how to type the ¦ symbol into xcode. If I copy and paste from a WP program xcode throws up an error when building the code.
I'm assuming that this is due to it being copied and pasted, unless xcode recognises another character as the OR bitwise operator?

Can anyone help?
For the broken bar character ¦ use "Character Viewer". It won't compile unless you use it in a string literal or a comment. For the vertical line character | - what keyboard do you have? Many keyboards have it printed on the keyboard, for others check out the "Keyboard Viewer".
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
I guess maybe I'm actually old enough to thing "WordPerfect" instead of "WordPress"?

-Lee
I actually did think of that, but I couldn't think of why someone would have a "program" in WordPerfect. You would think a C program from that era would be in .txt or some other plain text format/encoding.

I kinda assumed WordPress because it was more logical to myself that the OP was copying a program from someone's blog or tutorial.

Also I could see WordPress "stylizing" the text in some way by replacing | with ¦
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
For the broken bar character ¦ use "Character Viewer". It won't compile unless you use it in a string literal or a comment. For the vertical line character | - what keyboard do you have? Many keyboards have it printed on the keyboard, for others check out the "Keyboard Viewer".
You need to turn this feature on, its in...

System Preferences->Keyboard (Keyboard Tab)
AND
System Preferences->Language&Text (Input Sources tab)

EDIT: at least in 10.6, in earlier versions I believe it was only in Language&Text
 

Sydde

macrumors 68020
Aug 17, 2009
2,147
4,263
IOKWARDI
Typically, when you see "a WP program" it stands for the generic "Word Processor". Kind of an archaic phrase that has been out of usage for at least half a dozen Moores.
 

brightside1863

macrumors newbie
Original poster
Oct 7, 2010
3
0
Nottinghamshire, UK
You need to turn this feature on, its in...

System Preferences->Keyboard (Keyboard Tab)
AND
System Preferences->Language&Text (Input Sources tab)

EDIT: at least in 10.6, in earlier versions I believe it was only in Language&Text
Thanks. Having the character viewer on the menu bar will come in very handy. As for the broken bar, it keeps throwing up a 'stray 302' error when it's used in any code i'm writing.
Which from what I can find means that it's unrecognised?
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
7
USA
Thanks. Having the character viewer on the menu bar will come in very handy. As for the broken bar, it keeps throwing up a 'stray 302' error when it's used in any code i'm writing.
Which from what I can find means that it's unrecognised?
Does that include when used in a string literal? As mentioned earlier (post 6) it can't be used in code except in string literals.
 

gnasher729

Suspended
Nov 25, 2005
16,996
3,932
Thanks. Having the character viewer on the menu bar will come in very handy. As for the broken bar, it keeps throwing up a 'stray 302' error when it's used in any code i'm writing.
Which from what I can find means that it's unrecognised?
The "bitwise or" operator | and the "logical or" operator || are written using the vertical line, not the broken bar character. So yes, it won't compile, just like if you put any other random character in your code. For example, if (x ≠ y) won't compile either, nor will (a ≥ b) or (a ≤ b).


Does that include when used in a string literal? As mentioned earlier (post 6) it can't be used in code except in string literals.
Should work fine inside a string literal. What might come unexpected is that XCode will use UTF-8 for string literals, and the broken bar is not a single byte character. So strlen ("¦") will return 2, not 1 as you might expect.
 

brightside1863

macrumors newbie
Original poster
Oct 7, 2010
3
0
Nottinghamshire, UK
The "bitwise or" operator | and the "logical or" operator || are written using the vertical line, not the broken bar character. So yes, it won't compile, just like if you put any other random character in your code. For example, if (x ≠ y) won't compile either, nor will (a ≥ b) or (a ≤ b).




Should work fine inside a string literal. What might come unexpected is that XCode will use UTF-8 for string literals, and the broken bar is not a single byte character. So strlen ("¦") will return 2, not 1 as you might expect.

Whizzer! Thanks gnasher729.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.