Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# EditorConfig is awesome: https://EditorConfig.org

# Top-most EditorConfig file
root = true

# All files - UTF-8 encoding
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Markdown files
[*.md]
charset = utf-8
trim_trailing_whitespace = false

# Code files - 4 spaces
[*.{py,rs,go,java,c,cpp,h,hpp}]
charset = utf-8
indent_style = space
indent_size = 4

# JavaScript/TypeScript - 2 spaces
[*.{js,ts,jsx,tsx,json,yml,yaml}]
charset = utf-8
indent_style = space
indent_size = 2

# C# - 4 spaces
[*.cs]
charset = utf-8
indent_style = space
indent_size = 4

# Configuration files
[*.{toml,ini,cfg,conf}]
charset = utf-8
indent_style = space
indent_size = 2

# Shell scripts
[*.sh]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2

# Makefiles
[Makefile]
charset = utf-8
indent_style = tab

# Batch files
[*.{bat,cmd}]
charset = utf-8
end_of_line = crlf
47 changes: 47 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Set default behavior to automatically normalize line endings
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout
*.md text
*.txt text
*.json text
*.yml text
*.yaml text

# Declare files that will always have LF line endings on checkout
*.sh text eol=lf

# Denote all files that are truly binary and should not be modified
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.pdf binary

# Source code files - ensure UTF-8 encoding
*.py text working-tree-encoding=UTF-8
*.rs text working-tree-encoding=UTF-8
*.go text working-tree-encoding=UTF-8
*.js text working-tree-encoding=UTF-8
*.ts text working-tree-encoding=UTF-8
*.jsx text working-tree-encoding=UTF-8
*.tsx text working-tree-encoding=UTF-8
*.cs text working-tree-encoding=UTF-8
*.java text working-tree-encoding=UTF-8
*.c text working-tree-encoding=UTF-8
*.cpp text working-tree-encoding=UTF-8
*.h text working-tree-encoding=UTF-8
*.hpp text working-tree-encoding=UTF-8

# Configuration files
*.toml text working-tree-encoding=UTF-8
*.ini text working-tree-encoding=UTF-8
*.cfg text working-tree-encoding=UTF-8
*.conf text working-tree-encoding=UTF-8

# Documentation
*.md text working-tree-encoding=UTF-8
*.rst text working-tree-encoding=UTF-8
*.adoc text working-tree-encoding=UTF-8
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
# TypeAlias
# TypeAlias

A repository for documenting type alias best practices and Unicode handling across different programming languages.

## 📚 Documentation

- **[Unicode Handling Guide](UNICODE_HANDLING_GUIDE.md)** - Comprehensive guide for Unicode handling in Python, Rust, Go, JavaScript/TypeScript, and C#

## 🌍 Unicode Best Practices

This repository provides guidance on:

- **Source Code Encoding**: UTF-8 as project standard
- **String & Unicode**: Language-specific handling (Python, Rust, Go, JS/TS, C#)
- **Normalization**: Unicode equivalence comparison techniques
- **Internationalization**: Multi-language data structure patterns

### Quick Overview

Different languages handle Unicode differently:

| Language | String Type | Encoding | Notes |
|----------|------------|----------|-------|
| Python 3 | `str` | Unicode | Unicode by default |
| Rust | `String`/`&str` | UTF-8 | Guaranteed valid UTF-8 |
| Go | `string` | Byte sequence | Conventionally UTF-8 |
| JavaScript/TypeScript | `string` | UTF-16 | Beware of surrogate pairs |
| C# / .NET | `string` | UTF-16 | Beware of surrogate pairs |

### Key Considerations

1. **Encoding**: Always use UTF-8 for source files and data exchange
2. **Normalization**: Use NFC/NFD normalization for string comparison
3. **Code Points vs Bytes**: Understand the difference between byte length and character count
4. **Emojis & Combining Characters**: Be aware of grapheme clusters and surrogate pairs
5. **Localization Structure**: Use `Dictionary<Locale, TokenMap>` pattern for multi-language support

For detailed information, examples, and best practices, see the [Unicode Handling Guide](UNICODE_HANDLING_GUIDE.md).

## 🚀 Getting Started

The documentation in this repository is applicable to any project that needs to handle Unicode text properly. Choose your language and follow the relevant section in the guide.

## 📖 Contributing

Contributions are welcome! Please ensure all documentation files are saved in UTF-8 encoding.
Loading