public byte[] stringToBytesUTFCustom(String str) { char[] buffer1 = str.toCharArray(); byte[] b = new byte[buffer1.length << 1]; for(int i = 0; i < buffer1.length; i++) { int bpos = i << 1; b[bpos] = (byte) ((buffer1[i]&0xFF00)>>8); b[bpos + 1] = (byte) (buffer1[i]&0x00FF); } return b; } public String bytesToStringUTFCustom(byte[] bytes) { char[] buffer = new char[bytes.length >> 1]; for(int i = 0; i < buffer.length; i++) { int bpos = i << 1; char c = (char)(((bytes[bpos]&0x00FF)<<8) + (bytes[bpos+1]&0x00FF)); buffer[i] = c; } return new String(buffer); }
public static string textFileReader(string pathFileName) { string line; System.IO.StreamReader fs; try { fs = new System.IO.StreamReader(pathFileName, System.Text.Encoding.GetEncoding(874)); line = fs.ReadToEnd(); /* อ่าน Encode จาก String ที่อ่านมาได้จาก text file */ System.Text.Encoding encodeSource = System.Text.Encoding.GetEncoding(fs.CurrentEncoding.CodePage); fs.Close(); //* ............ */ System.Text.Encoding systemEncode = System.Text.Encoding.Default; System.Text.Encoding targetEncode = encodeSource; /* สั่ง getbyte array จาก string ที่เราอ่านมา */ byte[] srcData = systemEncode.GetBytes(line); byte[] dstData; /* ถ้าเป้น Encode ต่างกัน windows และ text file ให้ Convert byte array ไปเป็น windows encode */ // if (targetEncode != systemEncode) dstData = System.Text.Encoding.Convert(systemEncode, System.Text.Encoding.GetEncoding(874), srcData); // else // dstData = srcData; /* convert bytearray ไปเป็น string ด้วย windows encode */ return targetEncode.GetString(dstData); } catch (Exception ex) { throw new System.IO.IOException("cannot find " + pathFileName, ex); } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง