Convert plain text as numbers to encrypt using RSA All mathematical description of encryption functions assume, despite the use of the word plaintext, that the message to be encrypted is a sequence of numbers. For example RSA with $n=pq$ assumes that one wants to encrypt a number $x$ less than $n$  than a message consisting alphabets. It says encrypted form of $x$ is $x^e\pmod m$. Is there any (open) standard for converting text to numbers before encrypting?

As ASCII values go only up to 256. Does one take plain text, say 10 characters at a time, and read it as a 10-digit number in base 256? This is my own guess. I would actually want to know the exact standard followed in the industry.
Is there any (open) standard for converting text to numbers before encrypting?


Well, yes and no.

There is the Unicode standard which converts each character as a single code point. But that's not what you are after, you want to encode a complete text into a number.



To do this the standard way to operate is to use two conversions:


convert the text to bytes using a character-encoding;
convert the bytes to a (large) number.




Now RSA certainly operates on numbers, but the RSA PKCS#1 standard is defined to take bytes as input. So step 2 is an integral part of PKCS#1 called OS2IP. OS2IP means Octet String (bytes) to (two) Integer Primitive. OS2IP simply interprets the bytes as an unsigned, big endian number.

OS2IP however happens after padding, which is performed on the input bytes. Padding is required to make RSA secure.



So that leaves us with the first step: converting the text to bytes. Text is stored inside computers as a string of characters. Character encoding is what is used to convert a set of characters (an alphabet) to bytes. The most logical character encoding is no doubt UTF-8, which encodes most of the most common Unicode characters to a single byte, ASCII compatible representation.

Unicode with UTF-8 is definitely as close as you can get to a commonly accepted standard.



If you want to experiment with raw/textbook/unpadded RSA, you could first encode using ASCII or UTF-8, and convert the resulting bytes to a number using OS2IP - but keep in mind that this is insecure.