Superíndice y Subíndice
Convierte texto a caracteres Unicode de superíndice o subíndice. Soporta dígitos, letras y símbolos comunes.
Caracteres soportados:
Dígitos 0-9: ⁰¹²³⁴⁵⁶⁷⁸⁹
Preguntas Frecuentes
Implementación de Código
SUPERSCRIPT = str.maketrans(
"0123456789abcdefghijklmnoprstuvwxyzABDEGHIJKLMNOPRTUVW+-=()",
"⁰¹²³⁴⁵⁶⁷⁸⁹ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻᴬᴮᴰᴱᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴿᵀᵁⱽᵂ⁺⁻⁼⁽⁾"
)
SUBSCRIPT = str.maketrans(
"0123456789aehijklmnoprstx+-=()",
"₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜₓ₊₋₌₍₎"
)
def to_superscript(text: str) -> str:
return text.translate(SUPERSCRIPT)
def to_subscript(text: str) -> str:
return text.translate(SUBSCRIPT)
print(to_superscript("x2 + y2 = r2")) # x² + y² = r²
print(to_subscript("H2O")) # H₂OComments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.