Set locale to system default UTF-8

后端 未结 3 2102
盖世英雄少女心
盖世英雄少女心 2020-11-28 10:15

When running R inside rApache, the locale is inherited from the Apache webserver, and therefore Sys.getlocale() is always equal to \"C\". I would l

3条回答
  •  悲&欢浪女
    2020-11-28 11:00

    I guess you need to make a check for the OS. The locale names differ by OS, see the examples at the help file.

    ?Sys.getlocale()
    
    Examples
    
    Sys.getlocale()
    Sys.getlocale("LC_TIME")
    ## Not run: 
    Sys.setlocale("LC_TIME", "de")     # Solaris: details are OS-dependent
    Sys.setlocale("LC_TIME", "de_DE.utf8")   # Modern Linux etc.
    Sys.setlocale("LC_TIME", "de_DE.UTF-8")  # ditto
    Sys.setlocale("LC_TIME", "de_DE")  # OS X, in UTF-8
    Sys.setlocale("LC_TIME", "German") # Windows
    
    ## End(Not run)
    Sys.getlocale("LC_PAPER")          # may or may not be set
    
    ## Not run: 
    Sys.setlocale("LC_COLLATE", "C")   # turn off locale-specific sorting,
                                       # usually, but not on all platforms
    ## End(Not run)
    

提交回复
热议问题