Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combined Tashkeel cases. #10

Closed
MohHeader opened this issue Jul 21, 2017 · 5 comments
Closed

combined Tashkeel cases. #10

MohHeader opened this issue Jul 21, 2017 · 5 comments

Comments

@MohHeader
Copy link
Contributor

MohHeader commented Jul 21, 2017

Some Tashkeel are printed as separate letters instead of using the combined version.

Example Shaddah + Fatha should use the combined version of : 0xFC60 unicode.
https://www.compart.com/en/unicode/U+FC60

Working on a fix.
if fixed it,, will do a Merge Request ( or post the solution here )

Thanks

@MohHeader
Copy link
Contributor Author

	internal static string RemoveTashkeel(string str, out List<TashkeelLocation> tashkeelLocation)
	{
		tashkeelLocation = new List<TashkeelLocation>();
		char[] letters = str.ToCharArray();

		int index = 0;
		for (int i = 0; i < letters.Length; i++) {
			if (letters [i] == (char)0x064B) { // Tanween Fatha
				tashkeelLocation.Add (new TashkeelLocation ((char)0x064B, i));
				index++;
			} else if (letters [i] == (char)0x064C) { // DAMMATAN
				tashkeelLocation.Add (new TashkeelLocation ((char)0x064C, i));
				index++;
			} else if (letters [i] == (char)0x064D){ // KASRATAN
				tashkeelLocation.Add (new TashkeelLocation ((char)0x064D, i));
				index++;
			}else if (letters [i] == (char)0x064E) { // FATHA
				if(index > 0)
				{
					if(tashkeelLocation[index-1].tashkeel == (char)0x0651 ) // SHADDA
					{
						tashkeelLocation [index - 1].tashkeel = (char)0xFC60; // Shadda With Fatha
						continue;
					}
				}

				tashkeelLocation.Add (new TashkeelLocation ((char)0x064E, i));
				index++;
			} else if (letters [i] == (char)0x064F) { // DAMMA
				if (index > 0) {
					if (tashkeelLocation [index - 1].tashkeel == (char)0x0651) { // SHADDA
						tashkeelLocation [index - 1].tashkeel = (char)0xFC61; // Shadda With DAMMA
						continue;
					}
				}
				tashkeelLocation.Add (new TashkeelLocation ((char)0x064F, i));
				index++;
			} else if (letters [i] == (char)0x0650) { // KASRA
				if (index > 0) {
					if (tashkeelLocation [index - 1].tashkeel == (char)0x0651) { // SHADDA
						tashkeelLocation [index - 1].tashkeel = (char)0xFC62; // Shadda With KASRA
						continue;
					}
				}
				tashkeelLocation.Add (new TashkeelLocation ((char)0x0650, i));
				index++;
			} else if (letters [i] == (char)0x0651) { // SHADDA
				if(index > 0)
				{
					if(tashkeelLocation[index-1].tashkeel == (char)0x064E ) // FATHA
					{
						tashkeelLocation [index - 1].tashkeel = (char)0xFC60; // Shadda With Fatha
						continue;
					}

					if(tashkeelLocation[index-1].tashkeel == (char)0x064F ) // DAMMA
					{
						tashkeelLocation [index - 1].tashkeel = (char)0xFC61; // Shadda With DAMMA
						continue;
					}

					if(tashkeelLocation[index-1].tashkeel == (char)0x0650 ) // KASRA
					{
						tashkeelLocation [index - 1].tashkeel = (char)0xFC62; // Shadda With KASRA
						continue;
					}
				}

				tashkeelLocation.Add (new TashkeelLocation ((char)0x0651, i));
				index++;
			} else if (letters [i] == (char)0x0652) { // SUKUN
				tashkeelLocation.Add (new TashkeelLocation ((char)0x0652, i));
				index++;
			} else if (letters [i] == (char)0x0653) { // MADDAH ABOVE
				tashkeelLocation.Add (new TashkeelLocation ((char)0x0653, i));
				index++;
			}
		}

		string[] split = str.Split(new char[]{(char)0x064B,(char)0x064C,(char)0x064D,
			(char)0x064E,(char)0x064F,(char)0x0650,
			(char)0x0651,(char)0x0652,(char)0x0653,(char)0xFC60,(char)0xFC61,(char)0xFC62});

		str = "";

		foreach(string s in split)
		{
			str += s;
		}

		return str;
	}

@Konash
Copy link
Owner

Konash commented Aug 8, 2017

Is that the solution?
I would recommend a merge if so.

@MohHeader
Copy link
Contributor Author

It is working ( at least for me ),,,
Will create a merge request, 👍

@MohHeader
Copy link
Contributor Author

#11

@Konash
Copy link
Owner

Konash commented Aug 8, 2017 via email

@Konash Konash closed this as completed Aug 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants