How do you preserve the accents of a dragged text?

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

How do you preserve the accents of a dragged text?

Post by Mag » Mon Apr 15, 2013 7:31 pm

Hi all,

I have a card with a field where you can drag a file or drag some text from another application (e.g. Text Wrangler). The text is html code and you get plain text.

Well, when I drag a html file all works great, but when I drag the same text from the file the accents are missing.

I place here the code stripped from non-related parts. Hope to not removed important things.


Specific code:

Code: Select all

Case A. Dragged html file
if "files" is in keys(the dragData) then put last item of line 1 of filesPathList into theFilePath
put URL ("file:" & theFilePath) into textToProcess

Case B. Dragged html code
if "text" is in keys(the dragData) then put (the dragData["text"]) into textToProcess
Common code

Code: Select all

set the htmlText of the templateField to textToProcess
put the text of the templateField into fixedText
reset the templateField

set the unicodeText of field "outputField" to uniEncode (fixedText, "UTF8")
Any small or great help or info will be greatly appreciated :-)

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: How do you preserve the accents of a dragged text?

Post by jmburnod » Tue Apr 16, 2013 11:14 am

Hi Mag,
Interesting.
Can you post an exemple of input/output ?
Best regards
Jean-Marc
https://alternatic.ch

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How do you preserve the accents of a dragged text?

Post by Mag » Tue Apr 16, 2013 2:39 pm

Hi



This is the html text as it appairs in the site page (the home of Apple Sveden):

Code: Select all

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sv-SE" lang="sv-SE">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="Author" content="Apple Inc." />
	<meta name="viewport" content="width=1024" />
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, IE=9" />
	<link id="globalheader-stylesheet" rel="stylesheet" href="http://images.apple.com/global/nav/styles/navigation.css" type="text/css" />

	<title>Apple</title>
	<meta name="omni_page" content="Apple - Index/Tab" />
	<meta name="Description" content="Apple designar och skapar iPod och iTunes, bärbara och stationära Mac-datorer, operativsystemet OS X och revolutionerande iPhone och iPad." />
	<link rel="home" href="http://www.apple.com/se/" />
	<link rel="alternate" type="application/rss+xml" title="RSS" href="http://images.apple.com/se/main/rss/hotnews/hotnews.rss" />
	<link rel="index" href="http://www.apple.com/se/sitemap/" />
	<link rel="stylesheet" href="http://images.apple.com/se/global/styles/base.css" type="text/css" />
	<link rel="stylesheet" href="http://images.apple.com/v/home/s/styles/home.css" type="text/css" />
	<link rel="stylesheet" href="http://images.apple.com/v/home/s/styles/billboard.css" type="text/css" />
	<link rel="stylesheet" href="http://images.apple.com/se/home/styles/billboard.css" type="text/css" />
	<link rel="stylesheet" href="http://images.apple.com/se/home/styles/home.css" type="text/css" />
	<script src="http://images.apple.com/global/scripts/lib/prototype.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://images.apple.com/global/scripts/lib/scriptaculous.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://images.apple.com/global/scripts/lib/sizzle.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://images.apple.com/global/scripts/browserdetect.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://images.apple.com/global/scripts/apple_core.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://images.apple.com/global/scripts/search_decorator.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://images.apple.com/global/scripts/feedstatistics.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://images.apple.com/global/ac_base/ac_base.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://images.apple.com/global/ac_retina/ac_retina.js" type="text/javascript" charset="utf-8"></script>

	<script src="http://images.apple.com/global/scripts/promomanager.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://images.apple.com/v/home/s/scripts/home.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		Event.onDOMReady(function(){
			new AC.PromoManager('homepage-20121129-hero', 'hero');
			new AC.PromoManager('homepage-20121129-promo1', 'promo1');
		});
	</script>
</head>
<body id="home" class="home">
	<script type="text/javascript">
	var searchSection = 'global'; 
	var searchCountry = 'se';
</script>
<script src="http://images.apple.com/global/nav/scripts/globalnav.js" type="text/javascript" charset="utf-8"></script>
<nav id="globalheader" class="apple">
	<!--googleoff: all-->
	<ul id="globalnav" role="navigation">
		<li id="gn-apple"><a href="/se/"><span>Apple</span></a></li>
		<li id="gn-store"><a href="http://store.apple.com/se"><span>Store</span></a></li>
		<li id="gn-mac"><a href="/se/mac/"><span>Mac</span></a></li>
		<li id="gn-ipod"><a href="/se/ipod/"><span>iPod</span></a></li>
		<li id="gn-iphone"><a href="/se/iphone/"><span>iPhone</span></a></li>
		<li id="gn-ipad"><a href="/se/ipad/"><span>iPad</span></a></li>
		<li id="gn-itunes"><a href="/se/itunes/"><span>iTunes</span></a></li>
		<li id="gn-support" class="gn-last"><a href="/se/support/"><span>Support</span></a></li>
	</ul>
	<!--googleon: all-->
	<div id="globalsearch">
		<form action="/search/" method="post" class="search" id="g-search"><div class="sp-label">
			<label for="sp-searchtext">Search</label>
			<input type="text" name="q" id="sp-searchtext" accesskey="s" />
		</div></form>
		<div id="sp-magnify"><div class="magnify-searchmode"></div><div class="magnify"></div></div>
		<div id="sp-results"></div>
	</div>
</nav>
<script type="text/javascript">
	AC.GlobalNav.Instance = new AC.GlobalNav();
</script>

	<div id="top">
<!-- SiteCatalyst code version: H.8. Copyright 1997-2006 Omniture, Inc. -->


	
	




	


<script type="text/javascript">
/* RSID: */

var s_account="appleseglobal"

</script>


	<script type="text/javascript" src="http://images.apple.com/metrics/scripts/s_code_h.js"></script>



<script type="text/javascript">

s.pageName=AC.Tracking.pageName()+" (se)";
s.channel="www.se.homepage"


/* Browser Height and Device Type */
var platform = '';
if (s.u.match(/(kindle|silk-accelerated|android|webos|rim tablet os|windows phone)/i)) {
	platform = 'mobile other';
} else if (s.u.match(/windows/i)) {
	platform = 'windows';
}else if (s.u.match(/(iphone|ipod)/i)) {
	platform = 'iphone/ipod touch';
} else if (s.u.match(/(ipad)/i)) {
	platform = 'ipad';
}else if (s.u.match(/Mac OS X/i)){
		platform = 'Mac';
} else {
	platform = 'other';
}
s.eVar44=window.innerHeight;
s.eVar43=platform;

Event.onDOMReady(function() {
	function trackNav(link,loc) {
		link.observe('mousedown',function(){
			var propURL = null;
			if(propURL = link.down('img')){
				propURL = propURL.getAttribute('src');
				propURL = propURL.substring(propURL.lastIndexOf('/')+1, propURL.length);
			}
			if(propURL == null){
				propURL = link.getAttribute('href');
			}
			if (propURL != null) {
				var prefix=(loc=='hero')?'h@':'p@';
				AC.Tracking.trackClick({
					prop3: prefix + propURL + ' - ' + AC.Tracking.pageName()
				}, this, 'o', prefix + propURL + ' - ' + AC.Tracking.pageName());
			}
			
			//navigation tracking
			if(AC&&AC.Storage){
				AC.Storage.setItem('s_nav',loc,'0');
			}
		});
	}
	$$('#billboard a').each(function(link){
		trackNav(link,'hero');
	});
	$$('.promos a').each(function(link){
		trackNav(link,'promos');
	});
});


s.linkInternalFilters="javascript:,apple.com/se/"

/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code)</script>
<!-- End SiteCatalyst code version: H.8. -->
</div>
	<div id="main" data-hires="true">
		<article id="billboard">
			<section class="hero">
				<a href="/se/iphone/" class="block iphone" >
					<h1><img src="http://images.apple.com/se/home/images/billboard_iphone_title.png" height="136" width="735" alt="iPhone 5. Lätt att tycka om. Det är därför så många faller för den."  /></h1>
					<img src="http://images.apple.com/se/home/images/billboard_iphone_hero.jpg" height="528" width="763" alt="" class="hero-image"  />
				</a>
			</section>

			<section class="hero">
				<a href="/se/ipad/" class="block ipad">
					<h1><img src="http://images.apple.com/se/home/images/billboard_ipad_title.png" height="118" width="594" alt="iPad. Två storlekar. Passar till allt."  /></h1>
					<img src="http://images.apple.com/euro/home/b/screens_en/images/billboard_ipad_hero.jpg" height="607" width="510" alt="" class="hero-image"  />
				</a>
			</section>
		</article><!--/billboard-->

		<aside class="promos">
	<ul>
		<li class="first-child"><div class="curve-down">
			<a class="promo1" href="/se/ipad/"><img src="http://images.apple.com/se/home/images/promo_ipad.png" alt="iPad. Två storlekar. Passar till allt." width="237" height="185"  /></a> 
			<a class="promo1" href="/se/iphone/"><img src="http://images.apple.com/se/home/images/promo_iphone5.png" alt="iPhone 5. Lätt att tycka om. Det är därför så många faller för den." width="237" height="185"  /></a>
		</div></li>
		<li class="second-child"><div class="curve-down">
			<a class="promo2" href="/se/imac/"><img src="http://images.apple.com/se/home/images/promo_imac.png" alt="iMac. Prestanda och design. I framkant." width="237" height="185"  /></a>
		</div></li>
		<li class="third-child"><div class="curve-down">
			<a class="promo3" href="/se/ipod-touch/"><img src="http://images.apple.com/se/home/images/promo_ipodtouch.png" alt="iPod touch Framforskad för maximalt skoj." width="237" height="185" /></a>
		</div></li>
		<li class="last-child"><div class="curve-down">
			<a class="promo4" href="/se/macbook-pro/"><img src="http://images.apple.com/se/home/images/promo_macbook_pro.png" alt="MacBook Pro med Retina-skärm. Högsta upplösningen någonsin på en bärbar dator. Och den näst högsta." width="237" height="185"   /></a>
		</div></li>
	</ul>
</aside>
		
		<footer id="homefooter">
			<div id="links">
				<p class="left">Handla på <a href="http://store.apple.com/se/">Apple Online Store</a> (020-120 99 71), besök <a href="/se/retail/">Apple Store</a> eller hitta en <a href="/se/buy/">återförsäljare</a>.</p>				
				<ul class="piped right">
					<li><a href="/se/sitemap/" class="first">Webbplatsöversikt</a></li>
					<li><a href="/se/hotnews/">Senaste nytt</a></li>
					<li><a href="/se/rss/">RSS-strömmar</a></li>
					<li><a href="/se/pr/">Pressinfo</a></li>
					<li><a href="/se/environment/">Miljö</a></li>
					<li><a href="/jobs/se/">Jobb</a></li>
					<li><a href="/se/contact/">Kontakta oss</a></li>
				</ul>
			</div><!--/links-->

			<div class="sosumi">
				<p class="copyright">Copyright © 2013 Apple Inc. Alla rättigheter förbehålls.</p>
				<ul class="piped">
					<li><a href="/se/legal/" class="first" >Användningsvillkor</a></li>
					<li><a href="/se/privacy/">Integritetspolicy</a></li>
					<li><a href="/se/privacy/use-of-cookies/">Användning av cookies</a></li>
				</ul>
				<div id="worldwide">
					<a href="/choose-your-country/">
						<img src="http://images.apple.com/global/elements/flags/22x22/sweden.png" alt="Sverige" height="22" width="22" data-hires="true" />
						<span class="more">Välj land eller region</span>
					</a>
				</div>
			</div><!--/sosumi-->
		</footer><!--/homefooter-->
		
	</div><!--/main-->
</body>
</html>
This is as it appairs if I drag the file over the field (you can see that the accented letters are missing):

Code: Select all

Apple
Store
Mac
iPod
iPhone
iPad
iTunes
Support





Handla på Apple Online Store (020-120 99 71), besök Apple Store eller hitta en återförsäljare.

Webbplatsöversikt
Senaste nytt
RSS-strömmar
Pressinfo
Miljö
Jobb
Kontakta oss

Copyright © 2013 Apple Inc. Alla rättigheter förbehålls.

Användningsvillkor
Integritetspolicy
Användning av cookies
Välj land eller region 
This is how it appairs if I paste the html code (content on the file):

Code: Select all

Apple
Store
Mac
iPod
iPhone
iPad
iTunes
Support





Handla p Apple Online Store (020-120 99 71), besk Apple Store eller hitta en terfrsljare.

Webbplatsversikt
Senaste nytt
RSS-strmmar
Pressinfo
Milj
Jobb
Kontakta oss

Copyright  2013 Apple Inc. Alla rttigheter frbehlls.

Anvndningsvillkor
Integritetspolicy
Anvndning av cookies
Vlj land eller region 

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: How do you preserve the accents of a dragged text?

Post by jmburnod » Tue Apr 16, 2013 3:18 pm

Sorry, no idea.
I hope others can help
https://alternatic.ch

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How do you preserve the accents of a dragged text?

Post by Mag » Tue Apr 16, 2013 3:33 pm

Thank you jmburnod,

I think the great difference here is in those two lines:

Code: Select all

put URL ("file:" & theFilePath) into textToProcess

put (the dragData["text"]) into textToProcess
Maybe the accented letters are missed when putting the dragData in variable... who can say...

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How do you preserve the accents of a dragged text?

Post by Mag » Tue Apr 16, 2013 4:06 pm

OK, I done some more tests and learnt that the dragData text is already accent-compliant, instead the text I get from the file has to be fixed.

So, to solve the problem I use this for the text I get from file:

Code: Select all

set the unicodeText of field "outputField" to uniEncode (myText, "UTF8")
and I use this, from the text I get from dragData:

Code: Select all

put myText into field "outputField"
Thanks to all of you that have read the topic and tried to guess a solution!

ekek
Posts: 51
Joined: Fri Sep 21, 2012 9:33 am

Re: How do you preserve the accents of a dragged text?

Post by ekek » Sat Oct 12, 2013 2:28 am

try with ISOToMac function.

Example.

put ISOToMac (URL ("http://yoururl.com")) into fld "field"

Post Reply