revertSuperscripts function

String revertSuperscripts(
  1. String value
)

Reverts superscript characters in the given value to their normal equivalents.

  • Parameters:

    • value: The string to process.
  • Returns: A new string with all superscript characters reverted to normal.

  • Example:

    final result = revertSuperscripts('x²y³');
    print(result); // Outputs: x2y3
    

Implementation

String revertSuperscripts(String value) {
  final StringBuffer buffer = StringBuffer();

  for (int i = 0; i < value.length; i++) {
    final String char = value[i];
    buffer.write(kSuperscriptsReverse[char] ?? char);
  }

  return buffer.toString();
}