none
concatenating some str to one RRS feed

  • Question

  • hi

    when i try to concatenating some str to one

    the order is change

    for example

    str1 =number

    str2 = hebrew

    str3= number

    the str3 concatenating   to str1 and not to str2 i guess (if i concatenating   with "," is should be ok but i

    want fixed length

    some explain:

    i loop via list dictionary to get length and tag <> (from xml)

    after i loop via xml (treat xml like txt)

    and get the value between  TAG compare list exist and txt/xml exist if match i

    get the value between tag and concatenating  till end of list dictionary

    the problem:::::

    the concatenating   not by order because the hebrew is RTL i guess

    any suggestions?

    thanks

      for (int index = 0; index < dict.Count; index++)
                {
                    var item = dict.ElementAt(index);
                    var itemKey = item.Key;
                    var itemValue = item.Value;
                    
                    // int x = Int32.Parse(itemKey);
                    StringBuilder builder = new StringBuilder(itemValue);
                    builder.Replace("<", "</");
                    int lengthh = builder.Length;


                    StringBuilder builderWO = new StringBuilder(itemValue);
                    builderWO.Replace(">", "/>");
                   

                    foreach (string line in lines)
                    {
                        
                        int theFirstLen = line.Trim().IndexOf(itemValue);
                        int theLastLen = line.Trim().IndexOf(builder.ToString());
                        int theLastLenWO_OPEN = line.Trim().IndexOf(builderWO.ToString());
                     
                        if (theFirstLen >= 0 && theLastLen > 0 || theLastLenWO_OPEN >=0 )


                        {

                            if (theLastLenWO_OPEN >= 0) //mean that we need to put spaces only
                            {
                                SR_LEFT = SR_LEFT + "{" + i + ",-" + itemKey.Substring(0, itemKey.IndexOf(".")) + "}";
                                Console.WriteLine(itemKey.Length - itemKey.IndexOf("."));

                                SR_RIGHT = SR_RIGHT + new string(' ', Int32.Parse(itemKey.Substring(0, itemKey.IndexOf("."))));

                                i += 1;

                                break;
                            }

                            else
                            {
                                // Console.WriteLine(line.Trim().Substring(theFirstLen + lengthh, theLastLen - theFirstLen - lengthh));
                                SR_LEFT = SR_LEFT + "{" + i + ",-" + itemKey.Substring(0, itemKey.IndexOf(".")) + "}";
                                SR_RIGHT = SR_RIGHT  + line.Trim().Substring(theFirstLen + lengthh, theLastLen - theFirstLen - lengthh);

                                i += 1;

                                break;


                            }
                        }
                    }
                }
                            using (StreamWriter sw = new StreamWriter("C:\\TST.TEXT", false))
                            {

                                sw.WriteLine(SR_LEFT, SR_RIGHT);

                            }
            }









    when i try to concatenating some str to one

    the order is change

    for example

    str1 =number

    str2 = hebrew

    str3= number

    the str3 concatenating   to str1 and not to str2 i guess (if i concatenating   with "," is should be ok but i

    want fixed length

    some explain:

    i loop via list dictionary to get length and tag <> (from xml)

    after i loop via xml (treat xml like txt)

    and get the value between  TAG compare list exist and txt/xml exist if match i

    get the value between tag and concatenating  till end of list dictionary

    the problem:::::

    the concatenating   not by order because the hebrew is RTL i guess

    any suggestions?

    thanks

      for (int index = 0; index < dict.Count; index++)
                {
                    var item = dict.ElementAt(index);
                    var itemKey = item.Key;
                    var itemValue = item.Value;
                    
                    // int x = Int32.Parse(itemKey);
                    StringBuilder builder = new StringBuilder(itemValue);
                    builder.Replace("<", "</");
                    int lengthh = builder.Length;


                    StringBuilder builderWO = new StringBuilder(itemValue);
                    builderWO.Replace(">", "/>");
                   

                    foreach (string line in lines)
                    {
                        
                        int theFirstLen = line.Trim().IndexOf(itemValue);
                        int theLastLen = line.Trim().IndexOf(builder.ToString());
                        int theLastLenWO_OPEN = line.Trim().IndexOf(builderWO.ToString());
                     
                        if (theFirstLen >= 0 && theLastLen > 0 || theLastLenWO_OPEN >=0 )


                        {

                            if (theLastLenWO_OPEN >= 0) //mean that we need to put spaces only
                            {
                                SR_LEFT = SR_LEFT + "{" + i + ",-" + itemKey.Substring(0, itemKey.IndexOf(".")) + "}";
                                Console.WriteLine(itemKey.Length - itemKey.IndexOf("."));

                                SR_RIGHT = SR_RIGHT + new string(' ', Int32.Parse(itemKey.Substring(0, itemKey.IndexOf("."))));

                                i += 1;

                                break;
                            }

                            else
                            {
                                // Console.WriteLine(line.Trim().Substring(theFirstLen + lengthh, theLastLen - theFirstLen - lengthh));
                                SR_LEFT = SR_LEFT + "{" + i + ",-" + itemKey.Substring(0, itemKey.IndexOf(".")) + "}";
                                SR_RIGHT = SR_RIGHT  + line.Trim().Substring(theFirstLen + lengthh, theLastLen - theFirstLen - lengthh);

                                i += 1;

                                break;


                            }
                        }
                    }
                }
                            using (StreamWriter sw = new StreamWriter("C:\\TST.TEXT", false))
                            {

                                sw.WriteLine(SR_LEFT, SR_RIGHT);

                            }
            }








    oren t

    Monday, November 4, 2019 8:30 PM

Answers

  • hi

    i solved to join number with hebrew text by this:

    string strArabic = "N'سلام'";
    string strEnglish = ", '1test'";
    string LRM = ((char)0x200E).ToString();  // This is a LRM
    string cat = strArabic  + LRM +  strEnglish ;


    oren t

    • Marked as answer by oren turg Thursday, November 7, 2019 10:20 AM
    Wednesday, November 6, 2019 3:01 PM

All replies

  • I admit that I did not read all of your code,
    but a problem with RTL language and string concat was also in: 
    Format string in arabic language

    btw: why would you use your own string parsing instead of using a XML parser?
    Monday, November 4, 2019 9:32 PM
  • Hi oren turg, 

    Thank you for posting here.

    According to your question, I try to make a test on my side, but I need more information.

    Could you provide some data included in ‘dict’ and ‘lines’ ? It will help us to analyze your problem and make a test.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 5, 2019 9:07 AM
    Moderator
  • hi

    i solved to join number with hebrew text by this:

    string strArabic = "N'سلام'";
    string strEnglish = ", '1test'";
    string LRM = ((char)0x200E).ToString();  // This is a LRM
    string cat = strArabic  + LRM +  strEnglish ;


    oren t

    • Marked as answer by oren turg Thursday, November 7, 2019 10:20 AM
    Wednesday, November 6, 2019 3:01 PM
  • Hi oren turg,

    Thanks for your feedback.

    Is your problem solved? If so, please click "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 7, 2019 9:37 AM
    Moderator