Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2010
    Posts
    79
    Thanks
    15
    Thanked 2 Times in 2 Posts

    Difference of ' and ’ ?

    I noticed something today while I was using JS to replace, ' but apparently there two of them ( ’ and ' ).

    Does anyone know the difference between the two?
    Last edited by kenshn111; 06-27-2013 at 10:21 PM. Reason: VIPStephan has given me a very good answer. Thank you very much!

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,705
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    The straight quotes (" and ') are used in most programming languages to denote the start and end of a text string, while the “typographic apostrophe” and so-called “smart quotes” (‘’ and “” are usually not part of the programming language and can only be used inside text strings.

    For example:
    Code:
    function example() {
      return 'this is a string';
    }
    You will run into problems if you use a straight apostrophe in that text string because the parser thinks the string has ended while more text is following, generating an error:
    Code:
    function example() {
      return 'this is a string and you can't use a straight apostrophe here (without escaping it)';
    }
    You either need to escape the apostrophe character (\') or you can use the typographically correct character because that’s ignored in the programming language:
    Code:
    function example() {
      return 'this is a string and you can’t use a straight apostrophe here (without escaping it)';
    }

  • Users who have thanked VIPStephan for this post:

    kenshn111 (06-27-2013)

  • #3
    New Coder
    Join Date
    Feb 2013
    Posts
    37
    Thanks
    1
    Thanked 4 Times in 4 Posts
    They are indeed actually two different text symbols and can be trouble to any code if not sighted immediately.

    ' is an apostrophe, that is code friendly.
    ’ is a close single quote, that is not code friendly.


    VIPStephan also makes a good point on the other quotation marks that should be noticed and worked with in programming languages.

    InternetCandy - Geeky Blog

    FreeWebGoods.com - Free online resources for website or computer.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •