SlideShare una empresa de Scribd logo
1 de 9
Descargar para leer sin conexión
2014/2/23

Cocoa

#23

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

1/9
2014/2/23

Cocoa

#23

@interface NSString ( CocoaStudy23 )
-(id) initWithData:(NSData *)data IANACharSetName:(NSString *)charSetName;
@end
@implementation NSString ( CocoaStudy23 )
-(id) initWithData:(NSData *)data IANACharSetName:(NSString *)charSetName
{
CFStringEncoding cfCharset = CFStringConvertIANACharSetNameToEncoding((CFStringRef)charSetName);
NSStringEncoding nsCharset = CFStringConvertEncodingToNSStringEncoding(cfCharset);
return [self initWithData:data encoding:nsCharset];
}
@end
@implementation AppController
-(void) awakeFromNib
{

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

2/9
2014/2/23

Cocoa

#23

UInt8 cString[] = { 0x82, 0xA9, 0x82, 0xC8, 0x8A, 0xBF, 0x95, 0x5C, 0 };
NSData *streamedString = [NSData dataWithBytes:(void *)&cString length:sizeof cString];
NSString *testString = [[NSString alloc]initWithData:streamedString IANACharSetName:@"Shift-JIS"];
NSLog( testString );
}

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

3/9
2014/2/23

Cocoa

#23

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

4/9
2014/2/23

Cocoa

#23

-(void) awakeFromNib
{
NSString *targetFile = @"/Users/msyk/Documents/apple-reg.pdf";
NSString *prefMIMEType = [self preferedMIMETypeFromFile:targetFile];
NSLog( prefMIMEType );
targetFile = @"file.xls";
prefMIMEType = [self preferedMIMETypeFromFile:targetFile];
NSLog( prefMIMEType );
}
- (NSString *)preferedMIMETypeFromFile:(NSString *)targetFile
{
NSString *currentFileExtension = [targetFile pathExtension];
CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, (CFStringRef)currentFileExtension, NULL);
CFStringRef prefferdMIMEType = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType);
return (NSString *)prefferdMIMEType;
}

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

5/9
2014/2/23

Cocoa

#23

- (NSString *)preferedMIMETypeFromFile:(NSString *)targetFile
{
FSRef ref;
FSPathMakeRef ((unsigned char*)[targetFile fileSystemRepresentation], &ref, NULL);
CFDictionaryRef values = NULL;
CFStringRef attrs[] = { kLSItemContentType, kLSItemExtension, kLSItemRoleHandlerDisplayName };
CFStringRef prefferdMIMEType = NULL;
CFArrayRef attrNames = CFArrayCreate(NULL, (const void **)attrs, 3 , NULL);
if ( LSCopyItemAttributes(&ref, kLSRolesAll, attrNames, &values) == noErr ) {
CFTypeRef uti = CFDictionaryGetValue(values, kLSItemContentType);
CFStringRef extInfo = CFDictionaryGetValue(values, kLSItemExtension);
CFStringRef appInfo = CFDictionaryGetValue(values, kLSItemRoleHandlerDisplayName);
NSLog ( @"%@ -> %@ -> %@", uti, extInfo, appInfo );
prefferdMIMEType = UTTypeCopyPreferredTagWithClass( uti, kUTTagClassMIMEType );
}
if ( prefferdMIMEType == nil ) {
/* Your Own Codes */
}
return (NSString *)prefferdMIMEType;
}

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

6/9
2014/2/23

Cocoa

#23

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

7/9
2014/2/23

Cocoa

#23

struct LSItemInfoRecord {
LSItemInfoFlags flags; //調べた項目に対するフラグ情報。ビットごとに意味があるが調べるには以下の表の定義定数を使う
OSType filetype;
//ファイルタイプ
OSType creator;
//クリエイタ
CFStringRef extension; //ファイルの拡張子を示すCFStringへの参照(使用後のリリース必要)
CFStringRef iconFileName; //(未使用)
LSKindID kindID;
//(未使用)
};
typedef struct LSItemInfoRecord LSItemInfoRecord;

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

8/9
2014/2/23

Cocoa

#23

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

9/9

Más contenido relacionado

La actualidad más candente

What they don't tell you about JavaScript
What they don't tell you about JavaScriptWhat they don't tell you about JavaScript
What they don't tell you about JavaScript
Raphael Cruzeiro
 
Bristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steveBristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steve
Obsidian Software
 
실시간 인벤트 처리
실시간 인벤트 처리실시간 인벤트 처리
실시간 인벤트 처리
Byeongweon Moon
 

La actualidad más candente (20)

Kapacitor Alert Topic handlers
Kapacitor Alert Topic handlersKapacitor Alert Topic handlers
Kapacitor Alert Topic handlers
 
iPhone and Rails integration
iPhone and Rails integrationiPhone and Rails integration
iPhone and Rails integration
 
What they don't tell you about JavaScript
What they don't tell you about JavaScriptWhat they don't tell you about JavaScript
What they don't tell you about JavaScript
 
Java program-to-calculate-area-and-circumference-of-circle
Java program-to-calculate-area-and-circumference-of-circleJava program-to-calculate-area-and-circumference-of-circle
Java program-to-calculate-area-and-circumference-of-circle
 
Raw system logs processing with hive
Raw system logs processing with hiveRaw system logs processing with hive
Raw system logs processing with hive
 
MongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and MergingMongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and Merging
 
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
 
Data recovery using pg_filedump
Data recovery using pg_filedumpData recovery using pg_filedump
Data recovery using pg_filedump
 
Declarative Infrastructure Tools
Declarative Infrastructure Tools Declarative Infrastructure Tools
Declarative Infrastructure Tools
 
A little systemtap
A little systemtapA little systemtap
A little systemtap
 
Roots of a quadratic equation1
Roots of a quadratic equation1Roots of a quadratic equation1
Roots of a quadratic equation1
 
scalable machine learning
scalable machine learningscalable machine learning
scalable machine learning
 
Time Series Meetup: Virtual Edition | July 2020
Time Series Meetup: Virtual Edition | July 2020Time Series Meetup: Virtual Edition | July 2020
Time Series Meetup: Virtual Edition | July 2020
 
RxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScript
 
Java 7 new features
Java 7 new featuresJava 7 new features
Java 7 new features
 
Single qubit-gates operations
Single qubit-gates operationsSingle qubit-gates operations
Single qubit-gates operations
 
Bristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steveBristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steve
 
Add Some Fun to Your Functional Programming With RXJS
Add Some Fun to Your Functional Programming With RXJSAdd Some Fun to Your Functional Programming With RXJS
Add Some Fun to Your Functional Programming With RXJS
 
W3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascript
 
실시간 인벤트 처리
실시간 인벤트 처리실시간 인벤트 처리
실시간 인벤트 처리
 

Destacado

Objective-C Survives
Objective-C SurvivesObjective-C Survives
Objective-C Survives
S Akai
 

Destacado (6)

Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets Cocoa
 
Yet Another Max/MSP-Cocoa Communication
Yet Another Max/MSP-Cocoa CommunicationYet Another Max/MSP-Cocoa Communication
Yet Another Max/MSP-Cocoa Communication
 
The Dark Depths of iOS [CodeMash 2011]
The Dark Depths of iOS [CodeMash 2011]The Dark Depths of iOS [CodeMash 2011]
The Dark Depths of iOS [CodeMash 2011]
 
Core MIDI and Friends
Core MIDI and FriendsCore MIDI and Friends
Core MIDI and Friends
 
Objective-C Survives
Objective-C SurvivesObjective-C Survives
Objective-C Survives
 
Cocoa fundamentalswert
Cocoa fundamentalswertCocoa fundamentalswert
Cocoa fundamentalswert
 

Similar a Cocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプ

Store and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraStore and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and Cassandra
Deependra Ariyadewa
 
Cloudcamp scotland - Using cloud without losing control
Cloudcamp scotland - Using cloud without losing controlCloudcamp scotland - Using cloud without losing control
Cloudcamp scotland - Using cloud without losing control
Duncan Johnston-Watt
 
Alexander Pavlenko, Senior Java Developer, "Cassandra into"
Alexander Pavlenko, Senior Java Developer, "Cassandra into"Alexander Pavlenko, Senior Java Developer, "Cassandra into"
Alexander Pavlenko, Senior Java Developer, "Cassandra into"
Alina Vilk
 

Similar a Cocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプ (20)

High Performance Core Data
High Performance Core DataHigh Performance Core Data
High Performance Core Data
 
Store and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraStore and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and Cassandra
 
I os 13
I os 13I os 13
I os 13
 
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
 
Using Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraUsing Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into Cassandra
 
Cloudcamp scotland - Using cloud without losing control
Cloudcamp scotland - Using cloud without losing controlCloudcamp scotland - Using cloud without losing control
Cloudcamp scotland - Using cloud without losing control
 
TensorFlow BASTA2018 Machinelearning
TensorFlow BASTA2018 MachinelearningTensorFlow BASTA2018 Machinelearning
TensorFlow BASTA2018 Machinelearning
 
Map kit light
Map kit lightMap kit light
Map kit light
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
 
Using spark 1.2 with Java 8 and Cassandra
Using spark 1.2 with Java 8 and CassandraUsing spark 1.2 with Java 8 and Cassandra
Using spark 1.2 with Java 8 and Cassandra
 
Config interface
Config interfaceConfig interface
Config interface
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of Things
 
Migrating Babel from CommonJS to ESM
Migrating Babel     from CommonJS to ESMMigrating Babel     from CommonJS to ESM
Migrating Babel from CommonJS to ESM
 
Productionalizing spark streaming applications
Productionalizing spark streaming applicationsProductionalizing spark streaming applications
Productionalizing spark streaming applications
 
Alexander Pavlenko, Senior Java Developer, "Cassandra into"
Alexander Pavlenko, Senior Java Developer, "Cassandra into"Alexander Pavlenko, Senior Java Developer, "Cassandra into"
Alexander Pavlenko, Senior Java Developer, "Cassandra into"
 
Cassandra into
Cassandra intoCassandra into
Cassandra into
 
Cascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUGCascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUG
 
DOSUG Taking Apache Camel For A Ride
DOSUG Taking Apache Camel For A RideDOSUG Taking Apache Camel For A Ride
DOSUG Taking Apache Camel For A Ride
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1
 

Más de Masayuki Nii

Más de Masayuki Nii (20)

Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
 
トップエスイー勉強会2014第1回-INTER-Mediator
トップエスイー勉強会2014第1回-INTER-Mediatorトップエスイー勉強会2014第1回-INTER-Mediator
トップエスイー勉強会2014第1回-INTER-Mediator
 
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみるCocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
 
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
 
Cocoa勉強会#61-メインスレッド外でNSURLConnection
Cocoa勉強会#61-メインスレッド外でNSURLConnectionCocoa勉強会#61-メインスレッド外でNSURLConnection
Cocoa勉強会#61-メインスレッド外でNSURLConnection
 
Cocoa勉強会#23-カスタムシートとModality
Cocoa勉強会#23-カスタムシートとModalityCocoa勉強会#23-カスタムシートとModality
Cocoa勉強会#23-カスタムシートとModality
 
Cocoa勉強会#6-SQLiteをCocoaで使う
Cocoa勉強会#6-SQLiteをCocoaで使うCocoa勉強会#6-SQLiteをCocoaで使う
Cocoa勉強会#6-SQLiteをCocoaで使う
 
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
 
Cocoa勉強会#57-Baseによるローカライズまとめ
Cocoa勉強会#57-BaseによるローカライズまとめCocoa勉強会#57-Baseによるローカライズまとめ
Cocoa勉強会#57-Baseによるローカライズまとめ
 
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しないCocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
 
Cocoa勉強会#45-AWS SimpleDBを使ってみる
Cocoa勉強会#45-AWS SimpleDBを使ってみるCocoa勉強会#45-AWS SimpleDBを使ってみる
Cocoa勉強会#45-AWS SimpleDBを使ってみる
 
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビューCocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
 
Cocoa勉強会#33-意外に楽に使えるlibcurl
Cocoa勉強会#33-意外に楽に使えるlibcurlCocoa勉強会#33-意外に楽に使えるlibcurl
Cocoa勉強会#33-意外に楽に使えるlibcurl
 
Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する
Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号するCocoa勉強会#28-OpenSSLで暗号化したファイルを復号する
Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する
 
Cocoa勉強会#27-QuickLookプラグインの作り方
Cocoa勉強会#27-QuickLookプラグインの作り方Cocoa勉強会#27-QuickLookプラグインの作り方
Cocoa勉強会#27-QuickLookプラグインの作り方
 
Cocoa勉強会#37-シェイクイベントの実装
Cocoa勉強会#37-シェイクイベントの実装Cocoa勉強会#37-シェイクイベントの実装
Cocoa勉強会#37-シェイクイベントの実装
 
Cocoa勉強会#32-表形式のデータに順序を記録する方法
Cocoa勉強会#32-表形式のデータに順序を記録する方法Cocoa勉強会#32-表形式のデータに順序を記録する方法
Cocoa勉強会#32-表形式のデータに順序を記録する方法
 
Cocoa勉強会#35-iPhoneでのコピペとカスタムUI
Cocoa勉強会#35-iPhoneでのコピペとカスタムUICocoa勉強会#35-iPhoneでのコピペとカスタムUI
Cocoa勉強会#35-iPhoneでのコピペとカスタムUI
 
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
 
Cocoa勉強会#38-UITableViewテーブル内のナビゲーション
Cocoa勉強会#38-UITableViewテーブル内のナビゲーションCocoa勉強会#38-UITableViewテーブル内のナビゲーション
Cocoa勉強会#38-UITableViewテーブル内のナビゲーション
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Cocoa勉強会23-識別情報の変換〜文字エンコードとデータタイプ

  • 2. 2014/2/23 Cocoa #23 @interface NSString ( CocoaStudy23 ) -(id) initWithData:(NSData *)data IANACharSetName:(NSString *)charSetName; @end @implementation NSString ( CocoaStudy23 ) -(id) initWithData:(NSData *)data IANACharSetName:(NSString *)charSetName { CFStringEncoding cfCharset = CFStringConvertIANACharSetNameToEncoding((CFStringRef)charSetName); NSStringEncoding nsCharset = CFStringConvertEncodingToNSStringEncoding(cfCharset); return [self initWithData:data encoding:nsCharset]; } @end @implementation AppController -(void) awakeFromNib { file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html 2/9
  • 3. 2014/2/23 Cocoa #23 UInt8 cString[] = { 0x82, 0xA9, 0x82, 0xC8, 0x8A, 0xBF, 0x95, 0x5C, 0 }; NSData *streamedString = [NSData dataWithBytes:(void *)&cString length:sizeof cString]; NSString *testString = [[NSString alloc]initWithData:streamedString IANACharSetName:@"Shift-JIS"]; NSLog( testString ); } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html 3/9
  • 5. 2014/2/23 Cocoa #23 -(void) awakeFromNib { NSString *targetFile = @"/Users/msyk/Documents/apple-reg.pdf"; NSString *prefMIMEType = [self preferedMIMETypeFromFile:targetFile]; NSLog( prefMIMEType ); targetFile = @"file.xls"; prefMIMEType = [self preferedMIMETypeFromFile:targetFile]; NSLog( prefMIMEType ); } - (NSString *)preferedMIMETypeFromFile:(NSString *)targetFile { NSString *currentFileExtension = [targetFile pathExtension]; CFStringRef uti = UTTypeCreatePreferredIdentifierForTag( kUTTagClassFilenameExtension, (CFStringRef)currentFileExtension, NULL); CFStringRef prefferdMIMEType = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType); return (NSString *)prefferdMIMEType; } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html 5/9
  • 6. 2014/2/23 Cocoa #23 - (NSString *)preferedMIMETypeFromFile:(NSString *)targetFile { FSRef ref; FSPathMakeRef ((unsigned char*)[targetFile fileSystemRepresentation], &ref, NULL); CFDictionaryRef values = NULL; CFStringRef attrs[] = { kLSItemContentType, kLSItemExtension, kLSItemRoleHandlerDisplayName }; CFStringRef prefferdMIMEType = NULL; CFArrayRef attrNames = CFArrayCreate(NULL, (const void **)attrs, 3 , NULL); if ( LSCopyItemAttributes(&ref, kLSRolesAll, attrNames, &values) == noErr ) { CFTypeRef uti = CFDictionaryGetValue(values, kLSItemContentType); CFStringRef extInfo = CFDictionaryGetValue(values, kLSItemExtension); CFStringRef appInfo = CFDictionaryGetValue(values, kLSItemRoleHandlerDisplayName); NSLog ( @"%@ -> %@ -> %@", uti, extInfo, appInfo ); prefferdMIMEType = UTTypeCopyPreferredTagWithClass( uti, kUTTagClassMIMEType ); } if ( prefferdMIMEType == nil ) { /* Your Own Codes */ } return (NSString *)prefferdMIMEType; } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html 6/9
  • 8. 2014/2/23 Cocoa #23 struct LSItemInfoRecord { LSItemInfoFlags flags; //調べた項目に対するフラグ情報。ビットごとに意味があるが調べるには以下の表の定義定数を使う OSType filetype; //ファイルタイプ OSType creator; //クリエイタ CFStringRef extension; //ファイルの拡張子を示すCFStringへの参照(使用後のリリース必要) CFStringRef iconFileName; //(未使用) LSKindID kindID; //(未使用) }; typedef struct LSItemInfoRecord LSItemInfoRecord; file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html 8/9