开发者

ASP/HTML problem with spaces and monofonts

开发者 https://www.devze.com 2022-12-27 03:49 出处:网络
I have a ASP has a Function that converts ä to &auml so far so good. I have lets say space for 10 char\'s if there are more cut them of if there are less fill the space up with &nbsp\'s. .

I have a ASP has a Function that converts

ä to &auml so far so good.

I have lets say space for 10 char's if there are more cut them of if there are less fill the space up with &nbsp's. . Like this:

test &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp

but if i say "täst" it does this:

te &auml t &nbsp

It interprets the &auml not as one char it looks at it as 6 chars. Is there a clever way around that? This problem messes up my design because I need the right count of spaces. The whole thing goes into a big select box.

Of you have to开发者_JS百科 add a ; at the end of ever &... I could add them because the Editor would really interprt them.


Could you count the characters before you convert them?

So with the example of "täst", you would determine that you will need 6 &nbsp's. then convert the characters (te &auml t), then append the &nbsp's (te &auml t &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp).


Something like ? Don't shoot me of you get small errors, I can't test it now (don't have a server here) so so it's coded from heart:

function CountChars ( byval s )

dim i, inAmp, Result

   Result = 0
   inAmp = False
   for i = 1 to len(s)
      select case mid(s,i,1)
         case "&" 
            Result = Result + 1
            inAmp = True
         case ";"
            if inAmp then inAmp = False
         case else
             if not inAmp then Result = Result + 1
      end select
   next
   CountChars = Result
end function
0

精彩评论

暂无评论...
验证码 换一张
取 消