Find any Unicode character for a given code point here Code Charts - Scripts. Note that the search box at the top of the page takes a hexadecimal number.
But now, I have a problem: I need the displayable characters between chr 127 and 160. Is there a way to show the ANSI-charakters? The reason is, that I have to change decimal numbers in a character and send the string to a server, which works with ascii/ansi. Because the characters between 127 and 160 can't displayed in unicode, the server can't decode the string.
There are no displayable characters between 127 and 160 in Unicode, they are not valid code points (values). However 8bit character code pages do usually have displayable characters from 127 to 255 but they all differ so you need to know which code page is assumed before you know what the character codes between 127 and 255 are meant to represent. Note that ASCII only defines printable characters between 32 and 127. I don't know if it is formally standardised as such but the "ANSI" code page is probably 1252.
Because the characters between 127 and 160 can't displayed in unicode, the server can't decode the string.
That's not the reason. Unicode incorporates every printable character in use in the world today, and a lot that are of only historic interest as well. You don't say how you are sending the string to the server but the Unicode code points in Basic4ppc (.NET) will need converting to the code page that the server understands so that when you specify a character inside Basic4ppc it will be converted to the code page value that the server understands.
You can do this with BinaryFile.StringToBytes to get an array of bytes (8bit characters) converted from a string to the code page specified when you initialized a BinaryFile object with New2. You can then send the contents of the array to the server. My BytesConverter library can do similar conversions and can also read and write converted data from and to files directly rather than using the BinaryFile methods as an intermediate stage. There is a list of code page numbers in the ByesConverter help.
If you want to read strings from your server you will need to convert in the opposite direction from the server code page to Unicode.
But there is one thing, that I didn't understand! The ANSI-Codepage is 1252. When I use your BytesConverter, I get with the CodePageFileDemo for the codepage 1252 the following characters:
Same boring old reason. The string being written is a UTF16 string with invalid codepoints between 127 and 160 where Unicode has no characters defined. These are being replaced by question marks in the specified code page as they don't represent any characters. If instead you write the binary codes they will read back interpreted by whatever codepage you specify in Sub ReadCodePage, try 437 and 1252 and see the difference.
B4X:
Sub WriteCodePage
FileOpen(f1, AppPath & "\codepage.txt", cRandom)
For i = 32 To 255
FilePutByte(f1, i-32, i)
Next
FileClose(f1)
End Sub
I don't see the problem . That code fragment looks fine to me. It takes a byte value, assumed to be a codepage 1252 character value and converts it to a Unicode value - the following amendment shows the ANSI value, the character represented by that value and the Unicode value for that character.
B4X:
Sub App_Start
buffer(0)= 128
FileOpen(c1,"data.txt",cRandom)
bin.New2(c1,1252)
char = bin.BytesToString(buffer(),0,1)
msg = "ANSI value " & buffer(0) & " is character " & char & " is Unicode value " & Asc(char)
Msgbox(msg)
End Sub