Thread: Problem with RSString

Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19
  1. #11  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,528
    Thanks given
    573
    Thanks received
    1,410
    Rep Power
    2114
    Quote Originally Posted by Admiral Slee View Post
    Here you go

    Code:
    	/**
    	 * Write a string.
    	 * @param string The string.
    	 */
    	public void writeString(String string) {
    		writeBytes(getFormatedMessage(string));
    		writeByte(0);
    	}
    
             /**
    	 * Converts a string to an byte array.
    	 * @param message The message.
    	 * @return The byte array.
    	 */
    	public static final byte[] getFormatedMessage(String message) {
    		int i_0_ = message.length();
    		byte[] is = new byte[i_0_];
    		for (int i_1_ = 0; (i_1_ ^ 0xffffffff) > (i_0_ ^ 0xffffffff); i_1_++) {
    			int i_2_ = message.charAt(i_1_);
    			if (((i_2_ ^ 0xffffffff) >= -1 || i_2_ >= 128) && (i_2_ < 160 || i_2_ > 255)) {
    				if ((i_2_ ^ 0xffffffff) != -8365) {
    					if ((i_2_ ^ 0xffffffff) == -8219) {
    						is[i_1_] = (byte) -126;
    					} else if ((i_2_ ^ 0xffffffff) == -403) {
    						is[i_1_] = (byte) -125;
    					} else if (i_2_ == 8222) {
    						is[i_1_] = (byte) -124;
    					} else if (i_2_ != 8230) {
    						if ((i_2_ ^ 0xffffffff) != -8225) {
    							if ((i_2_ ^ 0xffffffff) != -8226) {
    								if ((i_2_ ^ 0xffffffff) == -711) {
    									is[i_1_] = (byte) -120;
    								} else if (i_2_ == 8240) {
    									is[i_1_] = (byte) -119;
    								} else if ((i_2_ ^ 0xffffffff) == -353) {
    									is[i_1_] = (byte) -118;
    								} else if ((i_2_ ^ 0xffffffff) != -8250) {
    									if (i_2_ == 338) {
    										is[i_1_] = (byte) -116;
    									} else if (i_2_ == 381) {
    										is[i_1_] = (byte) -114;
    									} else if ((i_2_ ^ 0xffffffff) == -8217) {
    										is[i_1_] = (byte) -111;
    									} else if (i_2_ == 8217) {
    										is[i_1_] = (byte) -110;
    									} else if (i_2_ != 8220) {
    										if (i_2_ == 8221) {
    											is[i_1_] = (byte) -108;
    										} else if ((i_2_ ^ 0xffffffff) == -8227) {
    											is[i_1_] = (byte) -107;
    										} else if ((i_2_ ^ 0xffffffff) != -8212) {
    											if (i_2_ == 8212) {
    												is[i_1_] = (byte) -105;
    											} else if ((i_2_ ^ 0xffffffff) != -733) {
    												if (i_2_ != 8482) {
    													if (i_2_ == 353) {
    														is[i_1_] = (byte) -102;
    													} else if (i_2_ != 8250) {
    														if ((i_2_ ^ 0xffffffff) == -340) {
    															is[i_1_] = (byte) -100;
    														} else if (i_2_ != 382) {
    															if (i_2_ == 376) {
    																is[i_1_] = (byte) -97;
    															} else {
    																is[i_1_] = (byte) 63;
    															}
    														} else {
    															is[i_1_] = (byte) -98;
    														}
    													} else {
    														is[i_1_] = (byte) -101;
    													}
    												} else {
    													is[i_1_] = (byte) -103;
    												}
    											} else {
    												is[i_1_] = (byte) -104;
    											}
    										} else {
    											is[i_1_] = (byte) -106;
    										}
    									} else {
    										is[i_1_] = (byte) -109;
    									}
    								} else {
    									is[i_1_] = (byte) -117;
    								}
    							} else {
    								is[i_1_] = (byte) -121;
    							}
    						} else {
    							is[i_1_] = (byte) -122;
    						}
    					} else {
    						is[i_1_] = (byte) -123;
    					}
    				} else {
    					is[i_1_] = (byte) -128;
    				}
    			} else {
    				is[i_1_] = (byte) i_2_;
    			}
    		}
    		return is;
    	}
    If I test that like this, its not working?
    Code:
    String s = "testing()";
    System.out.println("test: "+getFormatedMessage(s).toString());
    EDIT: prints the string if I change it to this... but its the same string, it hasnt replaced the symbols with something else...
    Code:
    String s = "testing()";
    System.out.println("test: "+new String(getFormatedMessage(s)));
    Number of page #1 releases with most views & posts: (Updated: 2023)
    RS2 server section: 1
    RS2 client section: 2
    Reply With Quote  
     

  2. #12  
    Registered Member

    Join Date
    Dec 2009
    Posts
    774
    Thanks given
    367
    Thanks received
    455
    Rep Power
    927
    Quote Originally Posted by mige5 View Post
    If I test that like this, its not working?
    Code:
    String s = "testing()";
    System.out.println("test: "+getFormatedMessage(s).toString());
    EDIT: prints the string if I change it to this... but its the same string, it hasnt replaced the symbols with something else...
    Code:
    String s = "testing()";
    System.out.println("test: "+new String(getFormatedMessage(s)));
    Nevermind. I was wrong, these are the "speical characters" which will be replaced:
    Code:
    private static char[] SPECIAL_CHARACTERS = {'€', '\0', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', '\0', 'Ž', '\0', '\0', '‘', '’', '“', '”', '•', '–', '—', '˜', '™', 'š', '›', 'œ', '\0', 'ž', 'Ÿ'};
    Looks like "(" and ")" are not special characters. What will show up when writing "(" and ")"? Also, what revision are you working in?
    Reply With Quote  
     

  3. #13  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,528
    Thanks given
    573
    Thanks received
    1,410
    Rep Power
    2114
    Quote Originally Posted by Admiral Slee View Post
    Nevermind. I was wrong, these are the "speical characters" which will be replaced:
    Code:
    private static char[] SPECIAL_CHARACTERS = {'€', '\0', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', '\0', 'Ž', '\0', '\0', '‘', '’', '“', '”', '•', '–', '—', '˜', '™', 'š', '›', 'œ', '\0', 'ž', 'Ÿ'};
    Looks like "(" and ")" are not special characters. What will show up when writing "(" and ")"? Also, what revision are you working in?
    Working with #459.

    Heres how this comes up:
    Code:
    ItemDef.stringToRSString(100, "te(st str)ing");
    Attached image
    Number of page #1 releases with most views & posts: (Updated: 2023)
    RS2 server section: 1
    RS2 client section: 2
    Reply With Quote  
     

  4. #14  
    Javascript junkie

    Join Date
    Oct 2017
    Posts
    49
    Thanks given
    8
    Thanks received
    9
    Rep Power
    21
    Quote Originally Posted by mige5 View Post
    Working with #459.

    Heres how this comes up:
    Code:
    ItemDef.stringToRSString(100, "te(st str)ing");
    Attached image
    This might be stupid but try adding a \ before the ( and )
    Reply With Quote  
     

  5. #15  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,528
    Thanks given
    573
    Thanks received
    1,410
    Rep Power
    2114
    any1?
    Number of page #1 releases with most views & posts: (Updated: 2023)
    RS2 server section: 1
    RS2 client section: 2
    Reply With Quote  
     

  6. #16  
    Registered Member

    Join Date
    Dec 2009
    Posts
    774
    Thanks given
    367
    Thanks received
    455
    Rep Power
    927
    Quote Originally Posted by mige5 View Post
    any1?
    I'm not familiar with 459. Probably wrong section. Can you share the RSString class.
    Reply With Quote  
     

  7. #17  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,528
    Thanks given
    573
    Thanks received
    1,410
    Rep Power
    2114
    Quote Originally Posted by Admiral Slee View Post
    I'm not familiar with 459. Probably wrong section. Can you share the RSString class.
    Heres the 459 one:
    https://pastebin.com/Rvz5eSej

    Heres 414 thats more refactored, so could possibly use as reference:
    https://pastebin.com/2GmNhnC9
    Number of page #1 releases with most views & posts: (Updated: 2023)
    RS2 server section: 1
    RS2 client section: 2
    Reply With Quote  
     

  8. #18  
    Registered Member

    Join Date
    Dec 2009
    Posts
    774
    Thanks given
    367
    Thanks received
    455
    Rep Power
    927
    Quote Originally Posted by mige5 View Post
    Heres the 459 one:
    https://pastebin.com/Rvz5eSej

    Heres 414 thats more refactored, so could possibly use as reference:
    https://pastebin.com/2GmNhnC9
    Try to replace your stringToRSString method with this one:
    Code:
    	public static String stringToRSString(int i, String s)
    	{
    		byte abyte0[] = s.getBytes();
    		int j = abyte0.length;
    		RSString class58 = new RSString();
    		int k = 0;
    		class58.aByteArray1894 = new byte[j];
    		while(k < j)
    		{
    			int l = 0xff & abyte0[k++];
    			/*if(~l >= -46 && ~l <= -41)
    			{
    				if(~k <= ~j)
    					break;
    				int i1 = 0xff & abyte0[k++];
    				//class58.aByteArray1894[class58.anInt1893++] = (byte)(43 * (l + -40) + (i1 - 48));
    			} else
    			if(l != 0)*/
    				class58.aByteArray1894[class58.anInt1893++] = (byte)l;
    		}
    		class58.method1049(57);
    		return class58.method1058(4096);
    	}
    Reply With Quote  
     

  9. Thankful user:


  10. #19  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,528
    Thanks given
    573
    Thanks received
    1,410
    Rep Power
    2114
    Quote Originally Posted by Admiral Slee View Post
    Try to replace your stringToRSString method with this one:
    Code:
    	public static String stringToRSString(int i, String s)
    	{
    		byte abyte0[] = s.getBytes();
    		int j = abyte0.length;
    		RSString class58 = new RSString();
    		int k = 0;
    		class58.aByteArray1894 = new byte[j];
    		while(k < j)
    		{
    			int l = 0xff & abyte0[k++];
    			/*if(~l >= -46 && ~l <= -41)
    			{
    				if(~k <= ~j)
    					break;
    				int i1 = 0xff & abyte0[k++];
    				//class58.aByteArray1894[class58.anInt1893++] = (byte)(43 * (l + -40) + (i1 - 48));
    			} else
    			if(l != 0)*/
    				class58.aByteArray1894[class58.anInt1893++] = (byte)l;
    		}
    		class58.method1049(57);
    		return class58.method1058(4096);
    	}
    Hey, that actually seems to work. Thx
    Number of page #1 releases with most views & posts: (Updated: 2023)
    RS2 server section: 1
    RS2 client section: 2
    Reply With Quote  
     

Page 2 of 2 FirstFirst 12

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. The problem with the community.
    By Mint in forum Complaints
    Replies: 10
    Last Post: 01-27-2008, 11:00 PM
  2. Problem....With Recoloring..
    By Wiffles in forum RS2 Client
    Replies: 0
    Last Post: 12-30-2007, 09:19 AM
  3. Problem With My Shop!!
    By 1337scape in forum RS2 Server
    Replies: 0
    Last Post: 09-15-2007, 05:53 PM
  4. Replies: 10
    Last Post: 08-31-2007, 10:41 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •