{"id":14066350,"url":"https://github.com/krlmlr/enc","last_synced_at":"2025-07-29T22:34:07.898Z","repository":{"id":9164209,"uuid":"61067212","full_name":"krlmlr/enc","owner":"krlmlr","description":"A simple class for storing UTF-8 strings","archived":true,"fork":false,"pushed_at":"2024-01-24T00:28:33.000Z","size":438,"stargazers_count":16,"open_issues_count":4,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-13T07:11:13.658Z","etag":null,"topics":["character-encoding","r","utf-8"],"latest_commit_sha":null,"homepage":"https://krlmlr.github.io/enc","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krlmlr.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-06-13T20:25:10.000Z","updated_at":"2024-04-26T04:09:19.000Z","dependencies_parsed_at":"2023-01-13T15:12:09.140Z","dependency_job_id":"a3053b9e-906a-451c-8341-4f0e785478fa","html_url":"https://github.com/krlmlr/enc","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krlmlr%2Fenc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krlmlr%2Fenc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krlmlr%2Fenc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krlmlr%2Fenc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krlmlr","download_url":"https://codeload.github.com/krlmlr/enc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228060050,"owners_count":17863358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["character-encoding","r","utf-8"],"created_at":"2024-08-13T07:05:03.395Z","updated_at":"2024-12-04T06:30:39.968Z","avatar_url":"https://github.com/krlmlr.png","language":"R","readme":"---\noutput: downlit::readme_document\n---\n\n# enc\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)\n[![rcc](https://github.com/krlmlr/enc/workflows/rcc/badge.svg)](https://github.com/krlmlr/enc/actions)\n[![codecov](https://codecov.io/gh/krlmlr/enc/branch/master/graph/badge.svg)](https://codecov.io/gh/krlmlr/enc)\n [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/enc)](https://cran.r-project.org/package=enc)\n\u003c!-- badges: end --\u003e\n\nPortable tools for UTF-8 character data\n\n## R and character encoding\n\nThe [character encoding](https://en.wikipedia.org/wiki/Character_encoding) of determines the translation of the letters, digits, or other codepoints (atomic components of a text) into a sequence of bytes. A byte sequence may translate into valid text in one character encoding, but give nonsense in other character encodings.\n\nFor historic reasons, R can store strings in different ways:\n\n1. in the \"native\" encoding, the default encoding of the operating system\n1. in [UTF-8](https://en.wikipedia.org/wiki/UTF-8), the most prevalent and versatile encoding nowadays\n1. in \"latin1\", a popular encoding in Western Europe\n1. as \"bytes\", leaving the interpretation to the user\n\nOn OS X and Linux, the \"native\" encoding is often UTF-8, but on Windows it is not. To add to the confusion, the encoding is a property of individual strings in a character vector, and not of the entire vector.\n\n## Why UTF-8?\n\nWhen working with text, it is advisable to use UTF-8, because it allows encoding virtually any text, even in foreign languages that contain symbols that cannot be represented in your system's native encoding. The UTF-8 encoding possesses several nice technical properties, and is by far the predominant encoding on the Web. Standardization on a \"universal\" encoding faciliates data exchange.\n\nBecause of R's special handling of strings, some care must be taken to make sure that you're actually using the UTF-8 encoding. Many functions in R will hide encoding issues from you, and transparently convert to UTF-8 as necessary. However, some functions (such as reading and writing files) will stubbornly prefer the native encoding.\n\nThe enc package provides helpers for converting all textual components of an object to UTF-8, and for reading and writing files in UTF-8 (with a LF end-of-line terminator by default). It also defines an S3 class for tagging all-UTF-8 character vectors and ensuring that updates maintain the UTF-8 encoding. Examples for other packages that use UTF-8 by default are:\n\n- [readr](https://readr.tidyverse.org/), [readxl](https://readxl.tidyverse.org/), and [haven](https://haven.tidyverse.org/) for data input and output\n\n- [stringi](https://cran.r-project.org/package=stringi) and [stringr](https://stringr.tidyverse.org/) for string manipulation\n\n- [testthat](https://testthat.r-lib.org/) and [roxygen2](https://cran.r-project.org/package=roxygen2) for package development\n\n## Example\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README-\"\n)\n```\n\n```{r}\nlibrary(enc)\nutf8(c(\"a\", \"ä\"))\nas_utf8(1)\n\na \u003c- utf8(\"ä\")\na[2] \u003c- \"ö\"\nclass(a)\n\ndata.frame(abc = letters[1:3], utf8 = utf8(letters[1:3]))\n```\n\nInstall the package from GitHub:\n\n```r\n# install.packages(\"devtools\")\ndevtools::install_github(\"krlmlr/enc\")\n```\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrlmlr%2Fenc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrlmlr%2Fenc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrlmlr%2Fenc/lists"}