#1
|
|||
|
|||
special characters renaming with eventscripter
I have some eventscripter using as packagizer hook to rename special characters when crawling content to get clean package names...
it is:: if (state = "AFTER") { var name = link.getPackageName(); if (name) { var newName = name; newName = newName.replace(/’/g, ""); newName = newName.replace("&", "and"); newName = newName.replace("@", "-"); newName = newName.replace("andamp;", "-"); newName = newName.replace("-r-", "-"); newName = newName.replace(" R-", "-"); newName = newName.replace(" r-", "-"); newName = newName.replace("xpost", "-"); newName = newName.replace("x-post", "-"); newName = newName.replace("https", "-"); newName = newName.replace("http", "-"); newName = newName.replace("-R-", "-"); newName = newName.replace("Xpost", "-"); newName = newName.replace("X-post", "-"); newName = newName.replace("XPost", "-"); newName = newName.replace("X-Post", "-"); newName = newName.replace("XPOST", "-"); newName = newName.replace("X-POST", "-"); newName = newName.replace(" IMG", "-"); newName = newName.replace("-IMG", "-"); newName = newName.replace(/'/g, ""); newName = newName.replace(/á/gi, "a"); newName = newName.replace(/é/gi, "e"); newName = newName.replace(/í/gi, "i"); newName = newName.replace(/ó/gi, "o"); newName = newName.replace(/ú/gi, "u"); newName = newName.replace(/ä/gi, "ae"); newName = newName.replace(/ö/gi, "oe"); newName = newName.replace(/ü/gi, "ue"); newName = newName.replace(/à/gi, "a"); newName = newName.replace(/è/gi, "e"); newName = newName.replace(/ì/gi, "i"); newName = newName.replace(/ò/gi, "o"); newName = newName.replace(/ù/gi, "u"); newName = newName.replace(/â/gi, "a"); newName = newName.replace(/ê/gi, "e"); newName = newName.replace(/î/gi, "i"); newName = newName.replace(/ô/gi, "o"); newName = newName.replace(/û/gi, "u"); newName = newName.replace(/ã/gi, "a"); newName = newName.replace(/ñ/gi, "n"); newName = newName.replace(/ç/gi, "c"); newName = newName.replace(/õ/gi, "o"); newName = newName.replace(/ø/gi, "o"); newName = newName.replace(/ý/gi, "y"); newName = newName.replace(/å/gi, "a"); newName = newName.replace(/ë/gi, "e"); newName = newName.replace(/ï/gi, "i"); newName = newName.replace(/ß/g, "ss"); newName = newName.replace(/ł/gi, "l"); newName = newName.replace(/æ/gi, "ae"); newName = newName.replace(/ð/gi, "d"); newName = newName.replace(/š/gi, "s"); newName = newName.replace(/č/gi, "c"); newName = newName.replace(/ñ/gi, "n"); newName = newName.replace(/ş/gi, "s"); newName = newName.replace(/ć/gi, "c"); newName = newName.replace(/ı/gi, "i"); newName = newName.replace(/ř/gi, "r"); newName = newName.replace(/ă/gi, "a"); newName = newName.replace(/İ/gi, "i"); newName = newName.replace(/č/gi, "c"); newName = newName.replace(/ş/gi, "s"); newName = newName.replace(/ć/gi, "c"); newName = newName.replace(/ı/gi, "i"); newName = newName.replace(/[^\x00-\x7F]/g, "-"); newName = newName.replace(/[!(\[)\]]/g, "-"); newName = newName.replace(/[,_{}|=~#%+]/g, "-"); if (name != newName) link.setPackageName(newName); } } and it is: if (state = "AFTER") { var name = link.getName(); var newName = name; var map = {}; if (name) { map.á = "a"; map.Á = "a"; map.é = "e"; map.í = "i"; map.ó = "o"; map.ú = "u"; map.à = "a"; map.è = "e"; map.ì = "i"; map.ò = "o"; map.ù = "u"; map.ä = "ae"; map.ö = "oe"; map.Ö = "oe"; map.ü = "ue"; map.ë = "e"; map.ï = "i"; map.ã = "a"; map.ñ = "n"; map.ç = "c"; map.ó = "o"; map.ú = "u"; map.ô = "o"; map.ê = "e"; map.õ = "o"; map.ø = "o"; map.ý = "y"; map.$ = "s"; map.å = "a"; map.î = "i"; map.â = "a"; map.û = "u"; map.ß = "ss"; map.æ = "ae"; map.ł = "l"; map.ð = "d"; map.š = "s"; map.č = "c"; map.ş = "s"; map.ć = "c"; map.ı = "i"; map.ř = "r"; map.č = "c"; map.ă = "a"; map.â = "a"; for (x in map) { newName = newName.replace(x, map[x]); } if (name != newName) link.setName(newName); } } but there are still some special characters for package names !? example links **External links are only visible to Support Staff****External links are only visible to Support Staff** **External links are only visible to Support Staff****External links are only visible to Support Staff** please tell me, what I am doing wrong!? |
#2
|
||||
|
||||
@verheiratet1952:
1.) why replace those chars in first place? your OS should not have problem with unicode chars 2.) a simple test with alert will show you that your way to replace the chars doesn't work see mathiasbynens.be/notes/javascript-unicode Easiest way to have the correct unicode character is to copy/paste the chars from the original string, then you would have seen that Code:
map.á= "1";
__________________
JD-Dev & Server-Admin Last edited by Jiaz; 03.10.2022 at 09:54. |
#3
|
|||
|
|||
Quote:
I just dont want any special characters for packagenames that are created for downloading... what do you mean with 'works fine' ... it works, but not for all special characters... sometimes same special character is renamed, sometimes not... the eventscripter code was send from MGPAI 1 or 2 years ago thru chat (https://jdownloader.org/knowledge/chat) |
#4
|
||||
|
||||
Thanks for the feedback and explanation
__________________
JD-Dev & Server-Admin |
#5
|
||||
|
||||
Quote:
Quote:
mot hereff.in/utf-8 (remove spaces to open this link) Code:
á results in \x61\xCC\x81 Code:
á results in \xC3\xA1
__________________
JD-Dev & Server-Admin Last edited by pspzockerscene; 04.10.2022 at 14:24. Reason: Made "mothereff.in/utf-8" link visible to user |
Thread Tools | |
Display Modes | |
|
|