Skip to content

Commit d748551

Browse files
committed
Print cyrillics in TEXT names properly.
1 parent 3d0167c commit d748551

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

machine.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,19 @@ std::string word_iso_string(Word w)
670670
return buf.str();
671671
}
672672

673+
//
674+
// Decode word as 8 characters in TEXT format.
675+
//
676+
std::string word_text_string(Word w)
677+
{
678+
std::ostringstream buf;
679+
for (int shift = 42; shift >= 0; shift -= 6) {
680+
unsigned ch = text_to_unicode(w >> shift);
681+
utf8_putc(ch, buf);
682+
}
683+
return buf.str();
684+
}
685+
673686
//
674687
// Decode word as filename in ISO format.
675688
// Remove trailing spaces, convert to lowercase.

machine.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ std::string tape_name_string(Word w);
339339
//
340340
std::string word_iso_string(Word w);
341341

342+
//
343+
// Decode word as string in TEXT format.
344+
//
345+
std::string word_text_string(Word w);
346+
342347
//
343348
// Decode word as filename in ISO format.
344349
// Remove trailing spaces, convert to lowercase.

session.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <vector>
3535

3636
#include "machine.h"
37-
#include "encoding.h"
3837

3938
//
4039
// Internal implementation of the simulation session, hidden from user.
@@ -266,14 +265,7 @@ class Session::Hidden {
266265
}
267266
Word location = machine.mem_load(BASE + addr + 1);
268267

269-
out << (char)std::tolower(text_to_unicode(name >> 42))
270-
<< (char)std::tolower(text_to_unicode(name >> 36))
271-
<< (char)std::tolower(text_to_unicode(name >> 30))
272-
<< (char)std::tolower(text_to_unicode(name >> 24))
273-
<< (char)std::tolower(text_to_unicode(name >> 18))
274-
<< (char)std::tolower(text_to_unicode(name >> 12))
275-
<< (char)std::tolower(text_to_unicode(name >> 6))
276-
<< (char)std::tolower(text_to_unicode(name)) << " ";
268+
out << word_text_string(name) << " ";
277269
besm6_print_word_octal(out, location);
278270
out << std::endl;
279271
}

0 commit comments

Comments
 (0)