के बाद char की संख्या बदलें मैं एक ऐसा ऐप्लिकेशन बना रहा हूं जो टेक्स्ट को ब्रेल में परिवर्तित कर दे। ब्रेल में कनवर्ट करना कोई समस्या नहीं है, लेकिन मुझे नहीं पता कि इसे वापस कैसे परिवर्तित किया जाए।एक विशिष्ट चार
उदाहरण 1: ब्रेल
को1 = #a
123 = #abc
12 45 = #ab #de
उदाहरण 2 संख्या परिवर्तित: ब्रेल
Jonas = ,jonas
JONAS = ,,jonas
में कनवर्ट कर रहा राजधानियों मैं सामान्य करने के लिए ब्रेल परिवर्तित वापस एक समस्या है। मैं बस हर a
से 1
और अन्य में परिवर्तित नहीं कर सकता। संख्याओं को #
द्वारा चेक किया जा सकता है और उसके बाद वर्णों को अगली जगह पर बदल दिया जा सकता है, लेकिन मुझे नहीं पता कि कैसे। पत्र से पहले अल्पविराम पाठ में अन्य अल्पविरामों से अलग होना मुश्किल है।
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace BrailleConverter
{
class convertingBraille
{
public Font getIndexBrailleFont()
{
return new Font("Index Braille Font", (float)28.5, FontStyle.Regular);
}
public Font getPrintableFontToEmbosser()
{
return new Font("Lucida Console", (float)28.5, FontStyle.Regular);
//return new Font("Index Black Text Font", (float)28.5, FontStyle.Regular);
}
public string convertCapitalsToUnderscore(string text)
{
if (string.IsNullOrEmpty(text))
{
return "";
}
text = " " + text;
text = text.Replace('.', '\'');
text = text.Replace(',', '1');
text = text.Replace('?', '5');
text = text.Replace('!', '6');
text = text.Replace(':', '3');
text = text.Replace('=', '7');
text = text.Replace('+', '4');
text = text.Replace('*', '9');
text = text.Replace('é', '=');
StringBuilder newText = new StringBuilder(text.Length * 2);
newText.Append(text[0]);
bool firstCapLetterInWord = true;
for (int i = 1; i < text.Length; i++)
{
char letter = text[i]; // Aktuell bokstav
char nextLetter = ' '; // Nästa bokstav
try
{
nextLetter = text[i + 1];
}
catch
{
}
// Är det stor bokstav?
if (char.IsUpper(letter))
{
// Är nästa bokstav stor?
if (char.IsUpper(nextLetter))
{
// Är det början av ett helt ord med caps?
if (firstCapLetterInWord)
{
newText.Append(",,"); // 2 st understräck framför ordet
firstCapLetterInWord = false; // Ändra så att inte nästa bokstav får 2 st understräck
}
}
else // Annars bara ett understräck
{
if (firstCapLetterInWord)
{
newText.Append(","); // Sätt understräck framför bokstav
}
firstCapLetterInWord = true; // Förbereda för nästa capsord
}
}
newText.Append(text[i]);
}
string finishedText = newText.ToString().TrimStart(); // Ta bort mellanslaget i början
finishedText = finishedText.ToLower();
finishedText = finishedText.Replace('å', '*');
finishedText = finishedText.Replace('ä', '>');
finishedText = finishedText.Replace('ö', '[');
return finishedText;
}
public string convertNumbersToBrailleNumbers(string text)
{
if (string.IsNullOrEmpty(text))
{
return "";
}
text = " " + text;
StringBuilder newText = new StringBuilder(text.Length * 2);
newText.Append(text[0]);
bool firstNumberInNumber = true;
for (int i = 1; i < text.Length; i++)
{
char letter = text[i]; // Aktuell tecken
char nextLetter = ' '; // Nästa tecken
try
{
nextLetter = text[i + 1];
}
catch
{
}
char convertedChar = text[i];
// Är tecknet en siffra?
if (char.IsNumber(letter))
{
// Är nästa tecken en siffra?
if (char.IsNumber(nextLetter))
{
// Är det början av ett flertaligt nummer?
if (firstNumberInNumber)
{
newText.Append('#'); // Brädkors framför nummret
firstNumberInNumber = false; // Ändra så att inte nästa siffra får brädkors
}
}
else // Annars bara ett understräck
{
if (firstNumberInNumber)
{
newText.Append('#'); // Sätt brädkors framför siffran
}
firstNumberInNumber = true; // Förbereda för nästa flertaliga nummer
}
}
newText.Append(convertedChar);
}
string finishedText = newText.ToString().TrimStart();
finishedText = finishedText.Replace('1', 'a');
finishedText = finishedText.Replace('2', 'b');
finishedText = finishedText.Replace('3', 'c');
finishedText = finishedText.Replace('4', 'd');
finishedText = finishedText.Replace('5', 'e');
finishedText = finishedText.Replace('6', 'f');
finishedText = finishedText.Replace('7', 'g');
finishedText = finishedText.Replace('8', 'h');
finishedText = finishedText.Replace('9', 'i');
finishedText = finishedText.Replace('0', 'j');
return finishedText;
}
public string convertBackToPrint(string oldText)
{
string newText = oldText.Replace(",", "");
newText = newText.Replace("#", "");
newText = newText.Replace("*", "å");
newText = newText.Replace(">", "ä");
newText = newText.Replace("[", "ö");
newText = newText.Replace('\'', '.');
newText = newText.Replace('1', ',');
newText = newText.Replace('5', '?');
newText = newText.Replace('6', '!');
newText = newText.Replace('3', ':');
newText = newText.Replace('7', '=');
newText = newText.Replace('4', '+');
newText = newText.Replace('9', '*');
newText = newText.Replace('=', 'é');
return newText;
}
}
}
आप अपने नमूना कोड पेस्ट कर सकता है? और पूर्ण बयान के साथ एक उदाहरण भी एक शब्द नहीं है। – VIRA
मेरी अज्ञानता क्षमा करें, लेकिन कागज पर उठाए गए बिंदुओं द्वारा बनाई गई ब्रेल नहीं है? – Jodrell
शायद आपको अल्पविरामों के बजाय कुछ और उपयोग करना चाहिए - प्रतीकों का कुछ अनुक्रम, जिसे शायद ही कभी पाठ में मिले जा सकते हैं: जोनास => @ #%^जोनास। इससे पहले कि आप व्यस्त संचालन को आसान बना सकें – horgh