LogoLogo
  • Internet Object 1.0
  • Internet Object
    • Abstract
    • The Poetic Principles of Internet Object
    • Objectives
    • Introducing Internet Object
  • The Structure
    • Internet Object Document
      • Header
      • Data Sections
    • Structural Elements
      • Structural Characters and Literals
      • Literals
      • Other Special Characters
      • Whitespaces
    • Values Representations
      • Objects
      • Arrays
      • Strings
        • Open Strings
        • Regular Strings
        • Raw Strings
      • Numeric Values
        • Number
        • BigInt
        • Decimal
        • Special Numeric Integer Formats
          • Hexadecimal
          • Octal
          • Binary
        • NaN and Infinity
      • Binary
      • Date and Time
      • Booleans
      • Nulls
    • Comments
    • Encoding
  • The Collections
    • Collection
    • Creating Collection
    • Collection Rules
    • Data Streaming
  • The Definitions
    • Definitions
    • Variables
    • Complex Schema
  • Schema Definition Language
    • Internet Object Schema
    • The structure
    • Data Types
      • Any
      • String
        • String Derived Types
          • Email
          • URL
          • Date
          • Time
          • DateTime
      • Number
        • Derived Types
          • int
          • byte
          • int16
          • int32
      • Object
      • Array
      • Bool
    • Dynamic Schema
    • Is Object, a MemberDef or a Schema?
  • Other
    • Best Practices
    • FAQs
    • Contributors
    • License
Powered by GitBook
On this page
  • Use Cases
  • Escaping

Was this helpful?

Edit on GitHub
Export as PDF
  1. The Structure
  2. Values Representations
  3. Strings

Raw Strings

PreviousRegular StringsNextNumeric Values

Last updated 1 year ago

Was this helpful?

In some cases (such as representing regular expressions) open string or regular string is not quite an efficient way to represent the string. Raw strings encapsulate the series of Unicode characters inside a single quote (' U+0027) character.

The Raw String

Use Cases

The raw string is used for representing text with complex characters. The following string represents an application path in the windows directory, it uses both characters i.e colon and backslash which makes it difficult to be represented using open strings and regular strings format.

'C:\program files\example\app.exe'

Raw strings format simplifies the complex string representation and enhances the readability by preventing escapes. The following regular expression is much more readable if represented using raw string format.

'^(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$'

As with other format of strings, raw strings can also deligently handle Unicode characters.

'जॉन डो', 'Can contain Ucharacters 😃'

Raw string preserves structural characters, newline characters, and whitespace while parsing

'A Unicode string (😃) which does not force you to escape
characters like \, \n or anything except a single quote 
char ''.'

Escaping

The Raw string does not support the character escaping with a reverse solidus. Every character inside the raw string is treated as exactly the same including reverse solidus (\ U+005C).

Only the single quote within the Raw string must be escaped to avoid string termination. To avoid the string termination, single quotes within the raw strings must be escaped using double single quotes.

'Jonas D''costa'