AkelPad Forum Index AkelPad
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fullwidth/halfwidth characters convert-html encode/decode

 
Post new topic   Reply to topic    AkelPad Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
shoshinsha



Joined: 05 Jul 2011
Posts: 17

PostPosted: Tue Jul 05, 2011 4:18 am    Post subject: Fullwidth/halfwidth characters convert-html encode/decode Reply with quote

Now, I'm working in Japanese.
I have searched a convert between halfwidth(katakana/ascii)/fullwidth plugin but no luck. So I decided to learn how to make akelpad plugin and made it myself.
Functions:
Quote:

Halfwidth Katakana" Call("Convert::FullKataToHalfKata")
"Fullwidth Katakana->Hiragana" Call("Convert::FullKataToHira")
"Halfwidth Katakana->Fullwidth Katakana" Call("Convert::HalfKataToFullKata")
"Halfwidth Katakana->Hiragana" Call("Convert::HalfKataToHira")
"Hiragana->Katakana" Call("Convert::HiraToFullKata")
"Hiragana->Halfwidth Katakana" Call("Convert::HiraToHalfKata")
"ASCII->Fullwidth ASCII" Call("Convert::FullwidthASCII")
"Fullwidth ASCII->ASCII" Call("Convert::HalfwidthASCII")
SEPARATOR(Plus)
"Html encode" Call("Convert::HtmlEncode")
"Html decode" Call("Convert::HtmlDecode")


download(dll & source)

For 4.7.6
Code:

http://www.mediafire.com/?0xay8569eeij7z9


Code:
http://www.mediafire.com/?ti4mw87v4a8jgcc


ps: I'm a beginner and my english is not good. Please, correct me if i'm wrong!

Update 7/7/2011:
-change unicode charaters->\x#### and numbers
-add Japanese messages
-compile with static libs
-macros->functions

@DV,FeyFre: Thanks!
Laughing Laughing Laughing Laughing Laughing Laughing Laughing

Update 2011/12/01
-Akelpad 4.7
-new html encode
Code:

SEPARATOR
"Convert"  Icon("%a\AkelFiles\Plugs\Convert.dll", 0)
{
  "Html"
  {
   "Encode"
      {
      #encode &<>"'
         "Escape" Call("Convert::HtmlEncode")   
         SEPARATOR
      #encode char > 0x7e
         "NonASCII" Call("Convert::HtmlEncode",0,1)
      #encode char > 0x7e using common entities (for char < 0xff)
         "NonASCII To Common Entities" Call("Convert::HtmlEncode",0,1,1)
      #encode char > 0x7e using entities
         "NonASCII To Entities" Call("Convert::HtmlEncode",0,1,2)
      #encode char > 0x7e with &#xxxx; format
         "NonASCII To Decimal" Call("Convert::HtmlEncode",0,1,3)
      #encode char > 0x7e with &#HHHH; format   
         "NonASCII To HEX" Call("Convert::HtmlEncode",0,1,3,1)
      #encode char > 0x7e with &#hhhh; format   
         "NonASCII To hex" Call("Convert::HtmlEncode",0,1,3,2)
         SEPARATOR
         "All" Call("Convert::HtmlEncode",0,1)
         "All To Common Entities" Call("Convert::HtmlEncode",0,2,1)
         "All To Entities" Call("Convert::HtmlEncode",0,2,2)
         "All To Decimal" Call("Convert::HtmlEncode",0,2,3)
         "All To HEX" Call("Convert::HtmlEncode",0,2,3,1)
         "All To hex" Call("Convert::HtmlEncode",0,2,3,2)
      }
   "Encode ignore existed entities"
      {
         "Escape" Call("Convert::HtmlEncode",1)
         SEPARATOR
         "NonASCII" Call("Convert::HtmlEncode",1,1)
         "NonASCII To Common Entities" Call("Convert::HtmlEncode",1,1,1)
         "NonASCII To Entities" Call("Convert::HtmlEncode",1,1,2)
         "NonASCII To Decimal" Call("Convert::HtmlEncode",1,1,3)
         "NonASCII To HEX" Call("Convert::HtmlEncode",1,1,3,1)
         "NonASCII To hex" Call("Convert::HtmlEncode",1,1,3,2)
         SEPARATOR
         "All" Call("Convert::HtmlEncode",1,1)
         "All To Common Entities" Call("Convert::HtmlEncode",1,2,1)
         "All To Entities" Call("Convert::HtmlEncode",1,2,2)
         "All To Decimal" Call("Convert::HtmlEncode",1,2,3)
         "All To HEX" Call("Convert::HtmlEncode",1,2,3,1)
         "All To hex" Call("Convert::HtmlEncode",1,2,3,2)
      }
   SEPARATOR
   "Decode" Call("Convert::HtmlDecode")
   
  }
  SEPARATOR
   "To FullWidth"
   {
      "Ascii" Call("Convert::FullwidthASCII")
      "Kata To Hira" Call("Convert::FullKataToHira")
      "Hira To Kata" Call("Convert::HiraToFullKata")
      "HalfKata To FullKata" Call("Convert::HalfKataToFullKata")
      "HalfKat To Hira" Call("Convert::HalfKataToHira")
      
   }
   "To HalfWidth"
   {
      "Ascii" Call("Convert::HalfwidthASCII")
      "FullKata To HalfKata" Call("Convert::FullKataToHalfKata")
      "Hira To HalfKata" Call("Convert::HiraToHalfKata")
   }
 
}


Last edited by shoshinsha on Thu Apr 18, 2013 3:30 pm; edited 8 times in total
Back to top
View user's profile Send private message
DV



Joined: 16 Nov 2006
Posts: 852
Location: Kyiv, Ukraine

PostPosted: Tue Jul 05, 2011 9:54 am    Post subject: Re: Fullwidth/halfwidth characters convert-html encode/decod Reply with quote

Looks good - at least, the implementation (omitting the fact that personally I don't know absolutely anything about Japanese Smile)
Regarding the functions, it's recommended to set pd->nUnload explicitely at the end of the function body, e.g.
Code:
pd->nUnload = UD_NONUNLOAD_NONACTIVE;

or
Code:
pd->nUnload = UD_NONUNLOAD_ACTIVE;

in case of a modeless dialog. Otherwise you may encounter unexpected behaviour and even a crash.
Though I did not find such assignments in the standard Format plugin, and it looks strange to me Smile Better ask Instructor about this.
Back to top
View user's profile Send private message
FeyFre



Joined: 07 Aug 2007
Posts: 2054
Location: Vinnitsa, Ukraine

PostPosted: Tue Jul 05, 2011 10:15 am    Post subject: Reply with quote

shoshinsha
Good work, although I have no chance to test it, but I believe it works in proper environment.

You made some no very good assumptions in your code, so unfortunately I could not check plugin carefully, so I made some notices for you:
1. Check
Code:
pd->dwSupport & PDS_GETSUPPORT
should be done unconditionally. When this flag is set you must set support flags: i.e
Code:
pd->dwSupport |= PDS_NOANSI|PDS_NOAUTOLOAD;

2. You are using Unicode literal(L-strings) explicitly, so you must use Unicode variants of API calls explicitly too(i.e you must SendMessageW, MessageBoxW, wsprintfW instead of SendMessage, MessageBox, wsprintf etc)
3. You have converted AkelDll.h into unicode(utf8). Unfortunately not all C-compilers support Unicode-encoded sources. MSVC <7.0/7.1 doesn't, so I could not compile it. About source file ConvertDll.c - you saved it in 932 codepage(Shift-JSI).. unfortunately MSVC 9.0 cannot recognize it correctly, but after conversion into utf8 it works.
4. More about Unicode: I'll advice you not to use Unicode symbols in sources directly, because of encoding problems(see 3). It is good idea to use them indirectly by means of \x#### escape sequences - they are portable(\u is not valid sequence), whereas direct symbols in some environments could be displayed incorrectly(for instance: I see them as boxes, because of my system hasn't CJK monospace fonts(Arial Unicde MS has CJK subset but it is not monospace so source is unreadable).
5. You used MSVC 10 (2010) to develop and build plugin. You have linked against shared version of libc library (msvcr100.dll). But you didn't provided us with SxS metadata: embedded manifest or manifest file with SxS dependencies. So plugin does not loads at all. You should create proper manifest or link against static version of libc(or do not use libs at all)
6. I think it is better to define FullKata2FullHira, HiraToFullkata and ___htmlEncode as function not as macros. Variant as function is easier to support, IMHO.

Good luck.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
shoshinsha



Joined: 05 Jul 2011
Posts: 17

PostPosted: Wed Jul 06, 2011 7:56 am    Post subject: Reply with quote

Thank you!
I will correct them soon.
Back to top
View user's profile Send private message
shoshinsha



Joined: 05 Jul 2011
Posts: 17

PostPosted: Thu Jul 07, 2011 5:20 am    Post subject: Reply with quote

Updated! Very Happy
Back to top
View user's profile Send private message
FeyFre



Joined: 07 Aug 2007
Posts: 2054
Location: Vinnitsa, Ukraine

PostPosted: Thu Jul 07, 2011 7:37 am    Post subject: Reply with quote

shoshinsha
You miss
Code:
if(pd->dwSupport & PDS_GETSUPPORT)
  return;
after
Code:
pd->dwSupport |= PDS_NOANSI|PDS_NOAUTOLOAD;
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
shoshinsha



Joined: 05 Jul 2011
Posts: 17

PostPosted: Thu Jul 07, 2011 11:29 am    Post subject: Re: Fullwidth/halfwidth characters convert-html encode/decod Reply with quote

FeyFre wrote:
shoshinsha
You miss
Code:
if(pd->dwSupport & PDS_GETSUPPORT)
  return;
after
Code:
pd->dwSupport |= PDS_NOANSI|PDS_NOAUTOLOAD;


fixed Laughing
thanks Rolling Eyes
Back to top
View user's profile Send private message
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5419

PostPosted: Thu Jul 07, 2011 1:24 pm    Post subject: Reply with quote

Only I see the very common purposes of "universalchardet/Japanese encoding detect plugin" and "Fullwidth/halfwidth characters convert-html encode/decode" Smile ?


"if (strEqual())" can be replaced with "if (!xstrcmpiW())".
Back to top
View user's profile Send private message Send e-mail
shoshinsha



Joined: 05 Jul 2011
Posts: 17

PostPosted: Wed Jul 13, 2011 11:11 am    Post subject: Reply with quote

Instructor wrote:
Only I see the very common purposes of "universalchardet/Japanese encoding detect plugin" and "Fullwidth/halfwidth characters convert-html encode/decode" Smile ?


"if (strEqual())" can be replaced with "if (!xstrcmpiW())".


Very Happy thanks!
Back to top
View user's profile Send private message
shoshinsha



Joined: 05 Jul 2011
Posts: 17

PostPosted: Thu Dec 01, 2011 9:55 am    Post subject: Reply with quote

update for akelpad 4.7
Back to top
View user's profile Send private message
shoshinsha



Joined: 05 Jul 2011
Posts: 17

PostPosted: Fri Jun 22, 2012 12:21 am    Post subject: Reply with quote

updated!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AkelPad Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SourceForge.net Logo Powered by phpBB © 2001, 2005 phpBB Group