Skip to main content

turkce-harf

Türkçe harfler için büyük/küçük harf dönüşümü, alfabe sıralaması ve arama anahtarı yardımcıları. Bağımlılığı yoktur.

Python'un standart upper()/lower() fonksiyonları Türkçe'yi bilmez: "i".upper() "I" döndürür, oysa Türkçe'de "İ" olmalıdır.

Kurulum

pip install turkce-harf

Kullanım

from turkce_harf import tr_lower, tr_upper, tr_title, tr_sort_key, tr_fold

tr_upper("istanbul")        # 'İSTANBUL'
tr_lower("ISPARTA")         # 'ısparta'
tr_title("ılık su")         # 'Ilık Su'

sorted(["şapka", "sabun", "ırmak"], key=tr_sort_key)
# ['ırmak', 'sabun', 'şapka']

tr_fold("Kılıç")            # 'kilic'  (yalnızca arama için)

# İngilizce metin için lang="en" kullan
tr_lower("IBM", lang="en")       # 'ibm'
tr_upper("istanbul", lang="en")  # 'ISTANBUL'

Her fonksiyon lang parametresi alır: "tr" (varsayılan) Türkçe kurallarını, "en" standart İngilizce kurallarını uygular. Karışık ya da İngilizce metinde lang="en" kullanmak I harfinin ı'ya dönüşmesini önler.

Fonksiyonlar

Tüm fonksiyonlar lang="tr" (varsayılan) ya da lang="en" alır.

  • tr_lower(text): Türkçe kurallarıyla küçük harf (I → ı, İ → i).
  • tr_upper(text): Türkçe kurallarıyla büyük harf (i → İ, ı → I).
  • tr_title(text): Her kelimenin ilk harfini büyütür, geri kalanı küçültür.
  • tr_sort_key(text): Türkçe alfabe sırasına göre sıralama anahtarı. Alfabe dışı karakterler sona gider.
  • tr_fold(text): Kayıplı arama anahtarı (ı→i, ş→s, ç→c, ğ→g, ö→o, ü→u). Saklanan veri için değil, yalnızca karşılaştırma için kullanın.
  • tr_nfc(text): Metni NFC biçimine getirir.

Geliştirme

pip install -e ".[test]"
pytest

Lisans

MIT


turkce-harf (English)

Helpers for uppercasing, lowercasing, Turkish alphabet sorting, and search keys for Turkish letters. No dependencies.

Python's standard upper()/lower() do not know Turkish: "i".upper() returns "I", but in Turkish it should be "İ".

Installation

pip install turkce-harf

Usage

from turkce_harf import tr_lower, tr_upper, tr_title, tr_sort_key, tr_fold

tr_upper("istanbul")        # 'İSTANBUL'
tr_lower("ISPARTA")         # 'ısparta'
tr_title("ılık su")         # 'Ilık Su'

sorted(["şapka", "sabun", "ırmak"], key=tr_sort_key)
# ['ırmak', 'sabun', 'şapka']

tr_fold("Kılıç")            # 'kilic'  (for search only)

# Use lang="en" for English text
tr_lower("IBM", lang="en")       # 'ibm'
tr_upper("istanbul", lang="en")  # 'ISTANBUL'

Every function accepts a lang parameter: "tr" (default) applies Turkish rules, and "en" applies standard English rules. Using lang="en" for mixed or English text prevents I from becoming ı.

Functions

All functions accept lang="tr" (default) or lang="en".

  • tr_lower(text): Lowercases with Turkish rules (I → ı, İ → i).
  • tr_upper(text): Uppercases with Turkish rules (i → İ, ı → I).
  • tr_title(text): Capitalizes the first letter of each word and lowercases the rest.
  • tr_sort_key(text): Sort key following the Turkish alphabet. Non-alphabet characters go last.
  • tr_fold(text): Lossy search key (ı→i, ş→s, ç→c, ğ→g, ö→o, ü→u). Use it only for comparison, not for stored data.
  • tr_nfc(text): Normalizes text to NFC form.

Development

pip install -e ".[test]"
pytest

License

MIT

Metadata

Release files for turkce-harf 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for turkce-harf 0.1.2
File Size Uploaded Provenance Actions
turkce_harf-0.1.2.tar.gz 5.9 kB Without provenance Details for turkce_harf-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for turkce-harf 0.1.2
File Interpreter ABI Platform Actions
turkce_harf-0.1.2-py3-none-any.whl Python 3 none any Details for turkce_harf-0.1.2-py3-none-any.whl

Total release size: 10.9 kB

Release files / turkce_harf-0.1.2.tar.gz

Download URL turkce_harf-0.1.2.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ec311c9fed7245880ad2e01c3efe8a449faa5e33344cb15d86353dd81b142425
BLAKE2b-256 checksum
How to use checksums
082ee112fc505e7dd39aad55a63f2df4be8d41798874f48970695556d2044857
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / turkce_harf-0.1.2-py3-none-any.whl

Download URL turkce_harf-0.1.2-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
752d1d272d9f9741eaf3db76bf3b598c45955f34b9eac8cc33f586239920daf3
BLAKE2b-256 checksum
How to use checksums
b73270c6d49099e3850e3f903181577a73ace3740db50b367e5580ee5af5b75b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Security for turkce-harf 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page